Is there any way to start the service on Android restart? See what I tried without success:
public class StartMyServiceAtBootReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
{
context.startForegroundService(new Intent(context, com.asterinet.react.bgactions.RNBackgroundActionsTask.class));
}
else
{
context.startService(new Intent(context, com.asterinet.react.bgactions.RNBackgroundActionsTask.class));
}
}
}
Error:
FATAL EXCEPTION: main
Process: br.com.auvo.app, PID: 17388
java.lang.RuntimeException: Unable to start service com.asterinet.react.bgactions.RNBackgroundActionsTask@bae1d25 with Intent { cmp=br.com.auvo.app/com.asterinet.react.bgactions.RNBackgroundActionsTask }: java.lang.IllegalArgumentException: Extras cannot be null
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:4794)
at android.app.ActivityThread.access$2000(ActivityThread.java:301)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2196)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:246)
at android.app.ActivityThread.main(ActivityThread.java:8595)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
Caused by: java.lang.IllegalArgumentException: Extras cannot be null
at com.asterinet.react.bgactions.RNBackgroundActionsTask.onStartCommand(RNBackgroundActionsTask.java:80)
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:4776)
... 8 more
Is there any way to start the service on Android restart? See what I tried without success:
Error: