C Creideiki Active Member Licensed User Longtime User Sep 26, 2020 #1 Hi, I wrote an app that receives intents which are sent by Tasker. The app worked till I got a new phone with Android 10. A little test app sends an intent and receives it itself. It was originally written with targetSdkVersion set to 14. In this version it worked (even with the Android 10 phone). Now I updated to targetSdkVersion 26 and it doesn't work any more. Code: Copy AddReceiverText(TargetService, <intent-filter> <action android:name="de.helmutbender.setstatus.NEW_STATUS" /> <data android:scheme="helmut" /> </intent-filter>) SetReceiverAttribute(TargetService, android:exported, true) Code: Copy Sub btISend_Click Dim myIntent As Intent myIntent.Initialize("de.helmutbender.setstatus.NEW_STATUS", "helmut://6") Dim p As Phone p.SendBroadcastIntent(myIntent) Log("IntentTester: Intent sent.") End Sub Code: Copy Sub Service_Start (StartingIntent As Intent) Log("IntentTest starting with " & StartingIntent.Action & " : " & StartingIntent.GetData) Service.StopAutomaticForeground 'Call this when the background task completes (if there is one) End Sub I read through the forum the last hours... I don't find what's wrong. What have I to do to make it work with Android 10?
Hi, I wrote an app that receives intents which are sent by Tasker. The app worked till I got a new phone with Android 10. A little test app sends an intent and receives it itself. It was originally written with targetSdkVersion set to 14. In this version it worked (even with the Android 10 phone). Now I updated to targetSdkVersion 26 and it doesn't work any more. Code: Copy AddReceiverText(TargetService, <intent-filter> <action android:name="de.helmutbender.setstatus.NEW_STATUS" /> <data android:scheme="helmut" /> </intent-filter>) SetReceiverAttribute(TargetService, android:exported, true) Code: Copy Sub btISend_Click Dim myIntent As Intent myIntent.Initialize("de.helmutbender.setstatus.NEW_STATUS", "helmut://6") Dim p As Phone p.SendBroadcastIntent(myIntent) Log("IntentTester: Intent sent.") End Sub Code: Copy Sub Service_Start (StartingIntent As Intent) Log("IntentTest starting with " & StartingIntent.Action & " : " & StartingIntent.GetData) Service.StopAutomaticForeground 'Call this when the background task completes (if there is one) End Sub I read through the forum the last hours... I don't find what's wrong. What have I to do to make it work with Android 10?
DonManfred Expert Licensed User Longtime User Sep 26, 2020 #2 Creideiki said: Now I updated to targetSdkVersion 26 and it doesn't work any more. Click to expand... Where is the full error from the log? Upvote 0
Creideiki said: Now I updated to targetSdkVersion 26 and it doesn't work any more. Click to expand... Where is the full error from the log?
C Creideiki Active Member Licensed User Longtime User Sep 26, 2020 #3 DonManfred said: Where is the full error from the log? Click to expand... Hm, sorry, I should have written that. There is no error. After sending the intent there just happens - nothing. The service isn't started. Not at all. Upvote 0
DonManfred said: Where is the full error from the log? Click to expand... Hm, sorry, I should have written that. There is no error. After sending the intent there just happens - nothing. The service isn't started. Not at all.
DonManfred Expert Licensed User Longtime User Sep 26, 2020 #4 check the unfiltered log also Does it make sense to send a broadcast intent just to receive it by the same app? Wouldn´t it be easier just to call a sub in the app instead of sending a broadcastintent? Have you tried to send the intent from another app? Upvote 0
check the unfiltered log also Does it make sense to send a broadcast intent just to receive it by the same app? Wouldn´t it be easier just to call a sub in the app instead of sending a broadcastintent? Have you tried to send the intent from another app?
C Creideiki Active Member Licensed User Longtime User Sep 26, 2020 #5 DonManfred said: Does it make sense to send a broadcast intent just to receive it by the same app? Wouldn´t it be easier just to call a sub in the app instead of sending a broadcastintent? Have you tried to send the intent from another app? Click to expand... No, certainly not. It's only a test app. The "original" app tries to recieve intents from Tasker. DonManfred said: check the unfiltered log also Click to expand... Hm... that's very much logging... but I found something: Code: Copy Background execution not allowed: receiving Intent { act=de.helmutbender.setstatus.NEW_STATUS dat=helmut://6 flg=0x10 } to de.helmutbender.intenttest/.targetservice$targetservice_BR Well, searching for "background execution" and then "foreground service" gives me many hits... so I will look into this. Thanks so far Upvote 0
DonManfred said: Does it make sense to send a broadcast intent just to receive it by the same app? Wouldn´t it be easier just to call a sub in the app instead of sending a broadcastintent? Have you tried to send the intent from another app? Click to expand... No, certainly not. It's only a test app. The "original" app tries to recieve intents from Tasker. DonManfred said: check the unfiltered log also Click to expand... Hm... that's very much logging... but I found something: Code: Copy Background execution not allowed: receiving Intent { act=de.helmutbender.setstatus.NEW_STATUS dat=helmut://6 flg=0x10 } to de.helmutbender.intenttest/.targetservice$targetservice_BR Well, searching for "background execution" and then "foreground service" gives me many hits... so I will look into this. Thanks so far
C Creideiki Active Member Licensed User Longtime User Sep 26, 2020 #6 When I read this, it seems, that B4A should handle that itself. And it doesn't work when the app is in forground either. So what am I doing wrong? Upvote 0
When I read this, it seems, that B4A should handle that itself. And it doesn't work when the app is in forground either. So what am I doing wrong?
C Creideiki Active Member Licensed User Longtime User Sep 27, 2020 #7 I found this and adapted it as follows: B4X: Copy myIntent.SetComponent("de.helmutbender.intenttest/.targetservice$targetservice_BR") Now it works. But WHY? What does SetComponent do and why is it necessary? ...and how can I tell Tasker to set the component? Upvote 0
I found this and adapted it as follows: B4X: Copy myIntent.SetComponent("de.helmutbender.intenttest/.targetservice$targetservice_BR") Now it works. But WHY? What does SetComponent do and why is it necessary? ...and how can I tell Tasker to set the component?
Erel B4X founder Staff member Licensed User Longtime User Sep 27, 2020 #8 Creideiki said: But WHY? Click to expand... Background Execution Limits | Android Developers New background limits for apps that target Android 8.0 or higher. developer.android.com Upvote 0
Creideiki said: But WHY? Click to expand... Background Execution Limits | Android Developers New background limits for apps that target Android 8.0 or higher. developer.android.com
C Creideiki Active Member Licensed User Longtime User Sep 27, 2020 #9 ok... there are only a view exceptions where broadcasts can be recieved by normal, in the manifest declared static implicit intents. So what can I do to get messages from other apps (Tasker, in my case)? 1) send the intent to a specific component (see above). Problem: I don't know how I can tell Tasker to do this... 2) Declare the broadcast receiver dynamically. Problem: this receiver could get killed in background. I can't be shure it runs. 3) I don't need a "broadcast" in this sense. I have one transmitter and one receiver. Tasker has a setting to create an intent that starts a service instead broadcasting. Problem: Neither I know how to setup Tasker correctly nor do I know how to setup the B4A app correctly... and I don't know what to search... Upvote 0
ok... there are only a view exceptions where broadcasts can be recieved by normal, in the manifest declared static implicit intents. So what can I do to get messages from other apps (Tasker, in my case)? 1) send the intent to a specific component (see above). Problem: I don't know how I can tell Tasker to do this... 2) Declare the broadcast receiver dynamically. Problem: this receiver could get killed in background. I can't be shure it runs. 3) I don't need a "broadcast" in this sense. I have one transmitter and one receiver. Tasker has a setting to create an intent that starts a service instead broadcasting. Problem: Neither I know how to setup Tasker correctly nor do I know how to setup the B4A app correctly... and I don't know what to search...
C Creideiki Active Member Licensed User Longtime User Oct 3, 2020 #10 So the answer of my question is: Receiving Broadcast Intents is much more difficult with new Android versions as before. The reason is linked by Erel above. It is possible, but the sender should set the component explicitly. Upvote 0
So the answer of my question is: Receiving Broadcast Intents is much more difficult with new Android versions as before. The reason is linked by Erel above. It is possible, but the sender should set the component explicitly.