Android Question [RESOLVED] One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for ....

Jmu5667

Well-Known Member
Licensed User
Longtime User
Hello

With the looming SDK 34 target approaching do we have any idea when B4A will be supporting the SDK 34 standard requirements. Our flagship app does not run when SDK 34 is set in the manifest file.

There are a number of failures generated, the title being one of them.

Regards

John.
 

Jmu5667

Well-Known Member
Licensed User
Longtime User
I use the broadcast receiver lib in one of my services:
B4X:
*** Service (br_receiver) Create ***
BroadcastReceiver has been initialized.
br_receiver_service_create (java line: 433)
java.lang.SecurityException: com.is.vitllinkSOS: One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts
    at android.os.Parcel.createExceptionOrNull(Parcel.java:3087)
    at android.os.Parcel.createException(Parcel.java:3071)
    at android.os.Parcel.readException(Parcel.java:3054)
    at android.os.Parcel.readException(Parcel.java:2996)
    at android.app.IActivityManager$Stub$Proxy.registerReceiverWithFeature(IActivityManager.java:5684)
    at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1868)
    at android.app.ContextImpl.registerReceiver(ContextImpl.java:1804)
    at android.app.ContextImpl.registerReceiver(ContextImpl.java:1792)
    at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:765)
    at com.rootsoft.broadcastreceiver.BroadCastReceiver.registerReceiver(BroadCastReceiver.java:52)
    at com.is.vitllinkSOS.br_receiver._service_create(br_receiver.java:433)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:221)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:201)
    at com.is.vitllinkSOS.br_receiver.onCreate(br_receiver.java:56)
    at android.app.ActivityThread.handleCreateService(ActivityThread.java:4915)
    at android.app.ActivityThread.-$$Nest$mhandleCreateService(Unknown Source:0)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2447)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loopOnce(Looper.java:257)
    at android.os.Looper.loop(Looper.java:368)
    at android.app.ActivityThread.main(ActivityThread.java:8826)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:572)
 
Upvote 0

Jmu5667

Well-Known Member
Licensed User
Longtime User
This is now sorted:

I needed to add the following in the manifest:

SetServiceAttribute(svc_service, android:foregroundServiceType, "location")
SetServiceAttribute(svc_serial, android:foregroundServiceType, "connectedDevice")

AddPermission(android.permission.FOREGROUND_SERVICE_LOCATION)
AddPermission(android.permission.FOREGROUND_SERVICE_CONNECTED_DEVICE)

I replaced a service that was using the broadcast receiver library with a receiver.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
The service svc_service is a long running background service that manages other services and functions of the application. I already use the FGS methods as you can see in the manifest file I already posted. svc_service handles the foregound notifcation, it does funtionality does not appear in the specific list of acceptable usages.
The error message in this post: https://www.b4x.com/android/forum/t...registered-exclusively-for.162106/post-994397 suggests that you are missing a foreground service type.

"it does funtionality does not appear in the specific list of acceptable usages"
Google will not accept it.

This thread is too confusing for me. I suggest you to start a new thread for any specific issue you encountered.
 
Upvote 0

Addo

Well-Known Member
Licensed User
Longtime User
This is now sorted:

I needed to add the following in the manifest:

SetServiceAttribute(svc_service, android:foregroundServiceType, "location")
SetServiceAttribute(svc_serial, android:foregroundServiceType, "connectedDevice")

AddPermission(android.permission.FOREGROUND_SERVICE_LOCATION)
AddPermission(android.permission.FOREGROUND_SERVICE_CONNECTED_DEVICE)

I replaced a service that was using the broadcast receiver library with a receiver.
It seems like you didn't see this post

 
Upvote 0

Computersmith64

Well-Known Member
Licensed User
Longtime User
Hello

With the looming SDK 34 target approaching do we have any idea when B4A will be supporting the SDK 34 standard requirements. Our flagship app does not run when SDK 34 is set in the manifest file.

There are a number of failures generated, the title being one of them.

Regards

John.
FWIW I recompiled a bunch of B4A apps to target SDK 34 the other day & released them all to Play Store without any issues. None of them were using receivers or services though...

- Colin.
 
Upvote 0

Computersmith64

Well-Known Member
Licensed User
Longtime User
This is the manifest:

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.basic4ppc.com/forum/showthread.php?p=78136

' // 2022.05.17 - EX710SYSTEM only supports upto SDK 29
#if EX710SYSTEM
    AddManifestText(
     <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="29"/>
     <supports-screens android:largeScreens="true"
         android:normalScreens="true"
         android:smallScreens="true"
        android:anyDensity="true"/>)
#else if PLAYSTORE
    AddManifestText(
         <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="34"/>
         <supports-screens android:largeScreens="true"
             android:normalScreens="true"
             android:smallScreens="true"
            android:anyDensity="true"/>)

#else
    AddManifestText(
         <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="34"/>
         <supports-screens android:largeScreens="true"
             android:normalScreens="true"
             android:smallScreens="true"
            android:anyDensity="true"/>)

#End if

' // Mark as SYSTEM APP
#if PLATFORM
    SetManifestAttribute(android:sharedUserId, "android.uid.system")
    ' // https://developer.android.com/guide/topics/manifest/application-element#persistent      
#End if


' // 2023.09.19 -  android:required="false" implemented to allow dumb devices install the app from the playstore
' // https://developer.android.com/guide/topics/manifest/uses-feature-element
' // https://developer.android.com/guide/topics/manifest/uses-feature-element#hw-features
AddManifestText(<uses-feature android:name="android.hardware.bluetooth" android:required="false"/>)
AddManifestText(<uses-feature android:name="android.hardware.bluetooth_le" android:required="false"/>)
AddManifestText(<uses-feature android:name="android.hardware.location.gps" android:required="false"/>)
AddManifestText(<uses-feature android:name="android.hardware.camera" android:required="false"/>)
AddManifestText(<uses-feature android:name="android.hardware.camera.autofocus" android:required="false"/>)
AddManifestText(<uses-feature android:name="android.hardware.camera.flash" android:required="false"/>)

' // APPLICATION
SetApplicationAttribute(android:theme, "@android:style/Theme.Holo")
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
#if WATCH
    SetApplicationAttribute(android:persistent, "True")
#end if

' // ACTIVITIES
SetActivityAttribute(main, android:launchMode, "singleTask")
SetActivityAttribute(main, android:clearTaskOnLaunch, "true")
SetActivityAttribute(main, android:windowSoftInputMode, adjustResize|stateHidden)
SetActivityAttribute(tpa_create,android:windowSoftInputMode, adjustResize|stateHidden)
SetActivityAttribute(tpa_running,android:windowSoftInputMode, adjustResize|stateHidden)
SetActivityAttribute(Settings, android:screenOrientation, "unspecified")
SetActivityAttribute(NewAppAvailable, android:theme, "@android:style/Theme.Translucent.NoTitleBar")

' // SERVICES
SetServiceAttribute(svc_ble, android:foregroundServiceType, "location")
SetServiceAttribute(svc_itag, android:foregroundServiceType, "location")
SetServiceAttribute(svc_gps, android:foregroundServiceType, "location")

SetApplicationAttribute(android:theme, "@style/MyAppTheme")

AddApplicationText(
                    <meta-data android:name="app_key_sos_data"
                               android:value="******************************************************************" />      
                                     
                    <meta-data android:name="app_key_sos_intent"
                               android:value="com.is.vitllinkSOS" />      
                                                
                    <meta-data android:name="app_key_sos_priority"
                                android:value="55" />          

                    <receiver android:name=".svc_intents$svc_intents_BR"
                              android:exported="true" >
                              <intent-filter>
                                      <action android:name="com.sonim.intent.action.SOS_KEY_DOWN" />
                                      <action android:name="com.sonim.intent.action.SOS_KEY_UP" />
                              </intent-filter>
                    </receiver>
                )
'' // Needed for SSL error fix
'AddApplicationText(
'                   <meta-data android:name="com.google.android.gms.version"
'                    android:value="@integer/google_play_services_version"/>
'                )

CreateResource(values, colors.xml,
                <resources>
                    <color name="actionbar">#ffC8001F</color>
                       <color name="statusbar">#ffC8001F</color>
                       <color name="navigationBar">#ffC8001F</color>
                </resources>
                )
CreateResource(values, themes.xml,
                <resources>
                    <style name="MyAppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
                        <item name="android:statusBarColor">@color/navigationBar</item>
                        <item name="android:navigationBarColor">@color/navigationBar</item>
                        <item name="windowNoTitle">true</item>
                        <item name="windowActionBar">false</item>
                        <item name="windowActionModeOverlay">true</item>      
                    </style>  
                </resources>
                )

' // 2023.07.10 - required for file handling - APK installs

AddApplicationText(
  <provider
  android:name="android.support.v4.content.FileProvider"
  android:authorities="$PACKAGE$.provider"
  android:exported="false"
  android:grantUriPermissions="true">
  <meta-data
  android:name="android.support.FILE_PROVIDER_PATHS"
  android:resource="@xml/provider_paths"/>
  </provider>
)
CreateResource(xml, provider_paths,
   <files-path name="name" path="shared" />
)
#if not(PLAYSTORE)
AddManifestText(<uses-permission
    android:name="android.permission.WRITE_EXTERNAL_STORAGE"
    android:maxSdkVersion="18" />
)  
    AddPermission(android.permission.REQUEST_INSTALL_PACKAGES)
#end if

#if not(PLATFORM) or not(EX710SYSTEM) or not(S10SYSTEM)
    ' // vitllink SOS hash key - Sonim Only
    AddManifestText(<meta-data android:name="app_key_sos_data" android:value="4ac9e6c316effb7be10a791055ef6c4c348b0ff76c3f51ede05f60e8a0896a90" />)
    AddManifestText(<meta-data android:name="app_key_sos_intent" android:value="com.is.vitllinkSOS" />)      
    AddManifestText(<meta-data android:name="app_key_sos_priority" android:value="55" />)
    ' // ECOM : https://support.ecom-ex.com/ecomfaq/item?id=1125&catid=303
    AddApplicationText(
    <meta-data android:name="ecom.device.key" android:value="alert" />
    <receiver
        android:name=".svc_intents$svc_intents_BR"
        android:enabled="true"
        android:exported="true">
        <intent-filter>
            <action android:name="com.ecom.intent.action.SOS_BUTTON_DOWN" />
            <action android:name="com.ecom.intent.action.SOS_BUTTON_UP" />     
        </intent-filter>
    </receiver>
    )
#end if

' // 2023.07.24 - enable checking of installed apps
AddManifestText(
    <queries>
        <package android:name="com.islesystems.launcher"/>
        <package android:name="com.islesystems.pushtotalk"/>
        <package android:name="com.islesystems.hello"/>      
        <package android:name="com.islesystems.criticalmessenger"/>      
        <package android:name="com.islesystems.sosvr"/>      
        <package android:name="com.android.vending"/>                      
    </queries>
    )
  


' // Overlay permissions
AddPermission(android.permission.SYSTEM_ALERT_WINDOW)
' // Location permissions
AddPermission(android.permission.ACCESS_COARSE_LOCATION)
AddPermission(android.permission.ACCESS_COARSE_UPDATES)
AddPermission(android.permission.ACCESS_BACKGROUND_LOCATION)
AddPermission(android.permission.ACCESS_FINE_LOCATION)
' // net
AddPermission(android.permission.ACCESS_NETWORK_STATE)
AddPermission(android.permission.ACCESS_WIFI_STATE)
' // bt
AddPermission(android.permission.BLUETOOTH)
AddPermission(android.permission.BLUETOOTH_SCAN)
AddPermission(android.permission.BLUETOOTH_CONNECT)
AddPermission(android.permission.BLUETOOTH_ADMIN)

AddPermission(android.permission.CAMERA)
AddPermission(android.permission.CHANGE_NETWORK_STATE)
AddPermission(android.permission.CHANGE_WIFI_STATE)
AddPermission(android.permission.FLASHLIGHT)
AddPermission(android.permission.INTERNET)

AddPermission(android.permission.READ_PHONE_STATE)
AddPermission(android.permission.MODIFY_PHONE_STATE)
AddPermission(android.permission.MODIFY_AUDIO_SETTINGS)

AddPermission(android.permission.RECEIVE_BOOT_COMPLETED)
AddPermission(android.permission.UPDATE_DEVICE_STATS)
AddPermission(android.permission.VIBRATE)
AddPermission(android.permission.WAKE_LOCK)
AddPermission(android.permission.SCHEDULE_EXACT_ALARM)
' // SMS
' // https://legalitgroup.com/en/sms-call-log-permissions-receive-approval-from-google-play-for-sensitive-permissions/
AddPermission(android.permission.SEND_SMS)

#if not(PLAYSTORE)  
    ' // calls
    AddPermission(android.permission.CALL_PHONE)
    AddPermission(android.permission.PROCESS_OUTGOING_CALLS)  
    AddPermission(android.permission.ANSWER_PHONE_CALLS)
    ' // SMS
    AddPermission(android.permission.RECEIVE_SMS)
    AddReceiverText(svc_sms_interceptor,
                    <intent-filter android:priority="2147483647">
                    <action android:name="android.provider.Telephony.SMS_RECEIVED" />
                    </intent-filter>)
#end if
' // Call
#if PLATFORM
    AddPermission(android.permission.CALL_PRIVILEGED)
#end if

AddPermission(android.permission.CALL_PHONE)
AddPermission(android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS)


' // 2019.10.21 - Allow home to reguest pincode
AddActivityText(svc_retrievepin, <intent-filter>
   <action android:name="com.is.vitllinkSOS.PINCODE" />
   <category android:name="android.intent.category.DEFAULT" />
</intent-filter>)

AddActivityText(svc_app_running, <intent-filter>
   <action android:name="com.islesystems.APP_RUNNING" />
   <category android:name="android.intent.category.DEFAULT" />
</intent-filter>)



AddReceiverText(svc_shutdown, <intent-filter> <action android:name="android.intent.action.ACTION_SHUTDOWN" /></intent-filter>)
' // intents from ToughShield Smartphone
AddReceiverText(svc_intents, <intent-filter> <action android:name="com.BrighterWirelessMain.Main.SOSDown"/></intent-filter>)
AddReceiverText(svc_intents, <intent-filter> <action android:name="com.BrighterWirelessMain.Main.SOSUp"/></intent-filter>)
' // Toughshield R500PLUS
AddReceiverText(svc_intents, <intent-filter> <action android:name="com.Toughshield.Main.SOSDown"/></intent-filter>)
AddReceiverText(svc_intents, <intent-filter> <action android:name="com.Toughshield.Main.SOSUp"/></intent-filter>)
' // MX2
AddReceiverText(svc_intents, <intent-filter> <action android:name="android.intent.action.ENTER_ONEKEYSOS"/></intent-filter>)
AddReceiverText(svc_intents, <intent-filter> <action android:name="android.intent.action.EXIT_ONEKEYSOS"/></intent-filter>)
' // CHINA PHONE
AddReceiverText(svc_intents, <intent-filter> <action android:name="com.android.action.F3_SOS"/></intent-filter>)  

' // V710
AddReceiverText(svc_intents, <intent-filter> <action android:name="shmaker.android.intent.action.KEYEVENT_DOWN_131"/></intent-filter>)      
AddReceiverText(svc_intents, <intent-filter> <action android:name="shmaker.android.intent.action.KEYEVENT_UP_131"/></intent-filter>)      
AddReceiverText(svc_intents, <intent-filter> <action android:name="shmaker.android.intent.action.KEYEVENT_DOWN_132"/></intent-filter>)      
AddReceiverText(svc_intents, <intent-filter> <action android:name="shmaker.android.intent.action.KEYEVENT_UP_132"/></intent-filter>)      
AddReceiverText(svc_intents, <intent-filter> <action android:name="shmaker.android.intent.action.KEYEVENT_DOWN_133"/></intent-filter>)      
AddReceiverText(svc_intents, <intent-filter> <action android:name="shmaker.android.intent.action.KEYEVENT_UP_133"/></intent-filter>)      
AddReceiverText(svc_intents, <intent-filter> <action android:name="shmaker.android.intent.action.KEYEVENT_DOWN_134"/></intent-filter>)      
AddReceiverText(svc_intents, <intent-filter> <action android:name="shmaker.android.intent.action.KEYEVENT_UP_134"/></intent-filter>)      
  
' // F22F25F887
AddReceiverText(svc_intents, <intent-filter> <action android:name="android.intent.action.SOS.now"/></intent-filter>)
AddReceiverText(svc_intents, <intent-filter> <action android:name="android.intent.action.sos.down"/></intent-filter>)
AddReceiverText(svc_intents, <intent-filter> <action android:name="android.intent.action.sos.up"/></intent-filter>)
AddReceiverText(svc_intents, <intent-filter> <action android:name="android.intent.action.sos"/></intent-filter>)
' // 2023.03.31
'AddReceiverText(svc_intents, <intent-filter> <action android:name="android.intent.action.sos_ticket"/></intent-filter>)

' // M31 - Android 10
AddReceiverText(br_receiver, <intent-filter> <action android:name="com.android.intent.SOS.down"/></intent-filter>)          
AddReceiverText(br_receiver, <intent-filter> <action android:name="com.android.intent.SOS.up"/></intent-filter>)
AddReceiverText(br_receiver, <intent-filter> <action android:name="android.intent.action.SOS.up"/></intent-filter>)
AddReceiverText(br_receiver, <intent-filter> <action android:name="android.intent.action.SOS.down"/></intent-filter>)
' // DOMI 9
AddReceiverText(br_receiver, <intent-filter> <action android:name="android.intent.action.SOS_LONG_PRESS"/></intent-filter>)

' // Generic
AddReceiverText(svc_intents, <intent-filter> <action android:name="android.intent.action.SOS_BUTTON"/></intent-filter>)
AddReceiverText(svc_intents, <intent-filter> <action android:name="android.intent.action.PTT.down"/></intent-filter>)
AddReceiverText(svc_intents, <intent-filter> <action android:name="android.intent.action.PTT.up"/></intent-filter>)
' // RugGear
AddReceiverText(svc_intents, <intent-filter> <action android:name="android.intent.action.CALL_FOR_HELP"/></intent-filter>)
AddReceiverText(svc_intents, <intent-filter> <action android:name="com.tdc.callforhelp.CallForHelpService"/></intent-filter>)
' // media key down/up
AddReceiverText(svc_intents, <intent-filter> <action android:name="vitllink.action.MEDIA_KEYDOWN"/></intent-filter>)
AddReceiverText(svc_intents, <intent-filter> <action android:name="vitllink.action.MEDIA_KEYUP"/></intent-filter>)
AddReceiverText(svc_intents, <intent-filter> <action android:name="vitllink.action.MEDIA_HEADPLUGIN"/></intent-filter>)
AddReceiverText(svc_intents, <intent-filter> <action android:name="vitllink.action.MEDIA_HEADPLUGOUT"/></intent-filter>)
AddReceiverText(svc_intents, <intent-filter> <action android:name="vitllink.action.MEDIA_SCREENON"/></intent-filter>)
AddReceiverText(svc_intents, <intent-filter> <action android:name="vitllink.action.MEDIA_SCREENOFF"/></intent-filter>)
' // doro phone
AddReceiverText(svc_intents, <intent-filter> <action android:name="com.doro.partner.action.ASSISTANCE_BUTTON_ACTIVATED"/></intent-filter>)


CreateResource(values-v20, theme.xml,
<resources>
    <style
        name="LightTheme" parent="@android:style/Theme.Material.Light">
    </style>
</resources>
)
CreateResource(values-v14, theme.xml,
<resources>
    <style
        name="LightTheme" parent="@android:style/Theme.Holo.Light">
    </style>
</resources>
)
CreateResourceFromFile(Macro, Core.NetworkClearText)
'End of default text.
I'm pretty sure I had that error a while back (I think it's been a thing since SDK 33 at least) in one of my AS apps & I'm pretty sure the fix was as simple as adding
B4X:
android:exported="true" '(or you can set it "false")
to the receiver declaration in the manifest - eg:
B4X:
<receiver
    android:name=".LanguageChangedReceiver"
    android:exported="true">
    <intent-filter>
        <action android:name="android.intent.action.LOCALE_CHANGED" />
    </intent-filter>
</receiver>

- Colin.
 
Upvote 0
Top