Rapsssito / react-native-background-actions

React Native background service library for running background tasks forever in Android & iOS.
MIT License
818 stars 117 forks source link

Unable to start service com.asterinet.react.bgactions.RNBackgroundActionsTask@7cf005d with Intent #237

Open saim683 opened 3 months ago

saim683 commented 3 months ago

java.lang.RuntimeException: Unable to start service com.asterinet.react.bgactions.RNBackgroundActionsTask@7cf005d with Intent { cmp=com.officermetrics/com.asterinet.react.bgactions.RNBackgroundActionsTask (has extras) }: java.lang.IllegalArgumentException: Cannot set both FLAG_IMMUTABLE and FLAG_MUTABLE for PendingIntent

I am using the latest version of react-native-background-actions. But when my app start's after 10 seconds my app goes to crash. I am using android 14.

RitheanyFT commented 3 months ago

🎉 This issue has been resolved in version 4.0.0 🎉

https://github.com/Rapsssito/react-native-background-actions/issues/200#issuecomment-2172709359

ctTushar commented 2 months ago

still issue persist

ctTushar commented 2 months ago

able to fixed it by add this patch

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.asterinet.react.bgactions">
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
    <application>
        <service android:name=".RNBackgroundActionsTask" android:foregroundServiceType="dataSync" />
    </application>
</manifest>
saim683 commented 2 months ago

It's working now. Thanks

On Thu, Aug 29, 2024 at 5:03 PM ctTushar @.***> wrote:

able to fixed it by add this


— Reply to this email directly, view it on GitHub https://github.com/Rapsssito/react-native-background-actions/issues/237#issuecomment-2317454460, or unsubscribe https://github.com/notifications/unsubscribe-auth/A5BZLLZ7PIE2D2YYVZ76ENTZT4E2HAVCNFSM6AAAAABMSGZF2KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMJXGQ2TINBWGA . You are receiving this because you authored the thread.Message ID: @.*** com>

vishalyad16 commented 2 months ago

@ctTushar @saim683 @RitheanyFT @gasolin

I am still experiencing crashes while sharing my screen, and this has been happening for the past four weeks. How can I resolve this issue? Please help.

`

<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
<application>
    <service android:name=".RNBackgroundActionsTask" android:foregroundServiceType="dataSync"/>
</application>

`

2)RNBackgroundTask.java final PendingIntent contentIntent; if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) { contentIntent = PendingIntent.getActivity(context,0, notificationIntent, PendingIntent.FLAG_MUTABLE | PendingIntent.FLAG_ALLOW_UNSAFE_IMPLICIT_INTENT); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_MUTABLE); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE); } else { contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); }

3) handleAppStateChange = async (nextAppState) => { if (nextAppState === 'active') { isPipOpen=true; console.log('videoAgora', 'ForeGround'); clearInterval(this.intervalReset); clearInterval(this.intervalBackground); //this.restartTranslationRecognition('User Reset'); await BackgroundService.stop(); this.resetTimer(); } else{ clearInterval(this.intervalReset); console.log('videoAgora', 'BackgroundStart'); BackgroundService.stop(); BackgroundService.start(this.veryIntensiveTask, this.options); try{ // if (isPipOpen) { // PipHandler.enterPipMode(300, 214); // isPipOpen=false; // } } catch(error){ } } this.setState({appState: nextAppState}); // console.log('state', nextAppState); };

"react-native-background-actions": "^4.0.0",

k-lpmg commented 2 months ago


In the official Android documentation below, it is written that additional processing is required for Android 14!
- https://developer.android.com/about/versions/14/changes/fgs-types-required