Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
saim683 opened this issue Aug 15, 2024 · 6 comments

Comments

@saim683
Copy link

saim683 commented Aug 15, 2024

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
Copy link

🎉 This issue has been resolved in version 4.0.0 🎉

#200 (comment)

@ctTushar
Copy link

still issue persist

@ctTushar
Copy link

ctTushar commented Aug 29, 2024

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
Copy link
Author

saim683 commented Aug 29, 2024 via email

@vishalyad16
Copy link

vishalyad16 commented Sep 2, 2024

@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.

<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>

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); }

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
Copy link

k-lpmg commented Sep 6, 2024

<manifest xmlns:android="http://schemas.android.com/apk/res/android">
    /// ...
    
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />


    // ...

    <application
      android:name=".MainApplication"
      android:label="@string/app_name"
      android:icon="@mipmap/ic_launcher"
      android:roundIcon="@mipmap/ic_launcher_round"
      android:allowBackup="true"
      android:theme="@style/AppTheme">

    // ...

      <service android:name="com.asterinet.react.bgactions.RNBackgroundActionsTask" android:foregroundServiceType="dataSync" />
    </application>
</manifest>

In the official Android documentation below, it is written that additional processing is required for Android 14!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants