I’m creating a React Native module to implement floating bubbles for Android. I’m using this package and need to create a service in AndroidManifest.xml
to run the bubble.
In the React Native app that imports the project, I can declare the service in the AndroidManifest.xml
like this:
<service
android:name="com.artotim.androidbubbleoverlay.FloatingBubble.FloatingBubbleService"
android:foregroundServiceType="specialUse">
<property
android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE"
android:value="explanation_for_special_use"/>
</service>
And everything works fine. However, I would like to declare the service in the react-native module’s AndroidManifest.xml
. Is it possible?
I tried adding the following to the module’s manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.artotim.androidbubbleoverlay">
<application>
<service
android:name=".FloatingBubble.FloatingBubbleService"
android:foregroundServiceType="specialUse">
<property
android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE"
android:value="explanation_for_special_use"
android:exported="false"/>
</service>
</application>
</manifest>
But when I try to start the service, I get the following error:
Unable to start service Intent { cmp=com.artotim.androidbubbleoverlay/.FloatingBubble.FloatingBubbleService } U=0: not found
Here is the code that I am using to start the service:
@ReactMethod
fun startFloatingBubbleService() {
val intent = Intent(reactApplicationContext, FloatingBubbleService::class.java)
ContextCompat.startForegroundService(reactApplicationContext, intent)
}
What am I doing wrong? How can I correctly declare the service in the module’s AndroidManifest.xml
and start it properly?