Android Question Broadcast Receiver API > 25

I want to receive broadcast intents in my app. I've tested broadcastreceiver library, and worked fine in the demo example, but when I add to my app with api 33, it doesn't work.
So I'm testing with new module of receiver type, adding the manifest, but I don't get the receive envent.
I've seen that the app receive broadcast with targetSdkVersion = "25" but with targetSdkVersion > 25, event Receiver_Receive don't fire up.
What is the problem?


this is my manifest.xml:

B4X:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: http://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="33"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
'End of default text.
AddPermission(android.permission.RECEIVE_ULTRASONIC_API)
AddReceiverText(myReceiver,
<intent-filter>
    <action android:name="com.my.app.CUSTOM_INTENT" />
</intent-filter>)

and this is myReceiver.bas module:

B4X:
Sub Process_Globals
   
End Sub

'Called when an intent is received.
'Do not assume that anything else, including the starter service, has run before this method.
Private Sub Receiver_Receive (FirstTime As Boolean, StartingIntent As Intent)  
    Log(StartingIntent)
End Sub
 

drgottjr

Expert
Licensed User
Longtime User
Upvote 0
I don't think that the behavior depends on the targetSdkVersion. The problem is somewhere else.

Make sure to run your app in RELEASE mode.
Yes, I run in release, and I only change targetSdkVersion and stop working.
 

Attachments

  • BroadCastReceiver.rar
    1.6 KB · Views: 91
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 2
I've added a menu item in the B4A app to self send an intent to the same app.
And guess... If I use sdk 25 works fine, and if I change to 33 fail!
I send you the B4A app to check.
The device where I'm testing have android 9.
 

Attachments

  • Sample.rar
    1.7 KB · Views: 112
Upvote 0
Upvote 0
Top