intent not initialize in process restart

melamoud

Active Member
Licensed User
hi,

I have this problem, if my service die (for example task manager) , when it get restarted by the OS (the service is sticky) it fail with a strange log saying the intent is not initialize,

anyone know why ?

this only happen if it restarted due to crush, it does not happen when I use startServiceAt

thanks

code:
B4X:
Sub Service_Start (StartingIntent As Intent)

   Log ("starting service of musicnotifier")
   Utilities.LogM(0,"intent =" & StartingIntent & "]")   
   Utilities.LogM(0,"intent extra=" & StartingIntent.ExtrasToString & "]")
   If (StartingIntent.HasExtra("scan")) Then Utilities.LogM(0,"intent extra scan=" & StartingIntent.GetExtra("scan") & "]")
   If (StartingIntent.HasExtra("alerts")) Then Utilities.LogM(0,"intent extra alerts=" & StartingIntent.GetExtra("alerts") & "]")
   If (StartingIntent.HasExtra("resolve")) Then Utilities.LogM(0,"intent extra resolve=" & StartingIntent.GetExtra("resolve") & "]")
   If (StartingIntent.HasExtra("alertsOne")) Then Utilities.LogM(0,"intent extra alertsOne=" & StartingIntent.GetExtra("alertsOne") & "]") ' debug only!!
   .......

logs:
B4X:
03-20 21:15:12.545 I/B4A     ( 4991): starting service of musicnotifier
03-20 21:15:12.560 I/B4A     ( 4991): 21:15:12 MNot:intent =(Intent) Not initialized]
03-20 21:15:12.568 I/B4A     ( 4991): 21:15:12 MNot:intent extra=not initialized]
03-20 21:15:12.615 I/B4A     ( 4991): scheduler_service_start (java line: 1227)
03-20 21:15:12.623 I/B4A     ( 4991): java.lang.RuntimeException: Object should first be initialized (Intent).
03-20 21:15:12.623 I/B4A     ( 4991):    at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:45)
03-20 21:15:12.623 I/B4A     ( 4991):    at anywheresoftware.b4a.objects.IntentWrapper.HasExtra(IntentWrapper.java:110)
03-20 21:15:12.623 I/B4A     ( 4991):    at appsright.musicnotifier.scheduler._service_start(scheduler.java:1227)
03-20 21:15:12.623 I/B4A     ( 4991):    at java.lang.reflect.Method.invokeNative(Native Method)
03-20 21:15:12.623 I/B4A     ( 4991):    at java.lang.reflect.Method.invoke(Method.java:511)
03-20 21:15:12.623 I/B4A     ( 4991):    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:167)
03-20 21:15:12.623 I/B4A     ( 4991):    at anywheresoftware.b4a.BA.raiseEvent(BA.java:151)
03-20 21:15:12.623 I/B4A     ( 4991):    at appsright.musicnotifier.scheduler.handleStart(scheduler.java:65)
03-20 21:15:12.623 I/B4A     ( 4991):    at appsright.musicnotifier.scheduler.onStartCommand(scheduler.java:50)
03-20 21:15:12.623 I/B4A     ( 4991):    at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2586)
03-20 21:15:12.623 I/B4A     ( 4991):    at android.app.ActivityThread.access$2000(ActivityThread.java:141)
03-20 21:15:12.623 I/B4A     ( 4991):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1364)
03-20 21:15:12.623 I/B4A     ( 4991):    at android.os.Handler.dispatchMessage(Handler.java:99)
03-20 21:15:12.623 I/B4A     ( 4991):    at android.os.Looper.loop(Looper.java:137)
03-20 21:15:12.623 I/B4A     ( 4991):    at android.app.ActivityThread.main(ActivityThread.java:5059)
03-20 21:15:12.623 I/B4A     ( 4991):    at java.lang.reflect.Method.invokeNative(Native Method)
03-20 21:15:12.623 I/B4A     ( 4991):    at java.lang.reflect.Method.invoke(Method.java:511)
03-20 21:15:12.623 I/B4A     ( 4991):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:792)
03-20 21:15:12.623 I/B4A     ( 4991):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555)
03-20 21:15:12.623 I/B4A     ( 4991):    at dalvik.system.NativeStart.main(Native Method)
03-20 21:15:12.631 W/dalvikvm( 4991): threadid=1: thread exiting with uncaught exception (group=0x40de52a0)
03-20 21:15:12.646 I/B4A     ( 4991): java.lang.RuntimeException: Unable to start service appsright.musicnotifier.scheduler@415f1040 with null: java.lang.RuntimeException: java.lang.RuntimeException: Object should first be initialized (Intent).
03-20 21:15:12.646 I/B4A     ( 4991):    at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2603)
03-20 21:15:12.646 I/B4A     ( 4991):    at android.app.ActivityThread.access$2000(ActivityThread.java:141)
03-20 21:15:12.646 I/B4A     ( 4991):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1364)
03-20 21:15:12.646 I/B4A     ( 4991):    at android.os.Handler.dispatchMessage(Handler.java:99)
03-20 21:15:12.646 I/B4A     ( 4991):    at android.os.Looper.loop(Looper.java:137)
03-20 21:15:12.646 I/B4A     ( 4991):    at android.app.ActivityThread.main(ActivityThread.java:5059)
03-20 21:15:12.646 I/B4A     ( 4991):    at java.lang.reflect.Method.invokeNative(Native Method)
03-20 21:15:12.646 I/B4A     ( 4991):    at java.lang.reflect.Method.invoke(Method.java:511)
03-20 21:15:12.646 I/B4A     ( 4991):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:792)
03-20 21:15:12.646 I/B4A     ( 4991):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555)
03-20 21:15:12.646 I/B4A     ( 4991):    at dalvik.system.NativeStart.main(Native Method)
03-20 21:15:12.646 I/B4A     ( 4991): Caused by: java.lang.RuntimeException: java.lang.RuntimeException: Object should first be initialized (Intent).
03-20 21:15:12.646 I/B4A     ( 4991):    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:193)
03-20 21:15:12.646 I/B4A     ( 4991):    at anywheresoftware.b4a.BA.raiseEvent(BA.java:151)
03-20 21:15:12.646 I/B4A     ( 4991):    at appsright.musicnotifier.scheduler.handleStart(scheduler.java:65)
03-20 21:15:12.646 I/B4A     ( 4991):    at appsright.musicnotifier.scheduler.onStartCommand(scheduler.java:50)
03-20 21:15:12.646 I/B4A     ( 4991):    at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2586)
03-20 21:15:12.646 I/B4A     ( 4991):    ... 10 more
03-20 21:15:12.646 I/B4A     ( 4991): Caused by: java.lang.RuntimeException: Object should first be initialized (Intent).
03-20 21:15:12.646 I/B4A     ( 4991):    at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:45)
03-20 21:15:12.646 I/B4A     ( 4991):    at anywheresoftware.b4a.objects.IntentWrapper.HasExtra(IntentWrapper.java:110)
03-20 21:15:12.646 I/B4A     ( 4991):    at appsright.musicnotifier.scheduler._service_start(scheduler.java:1227)
03-20 21:15:12.646 I/B4A     ( 4991):    at java.lang.reflect.Method.invokeNative(Native Method)
03-20 21:15:12.646 I/B4A     ( 4991):    at java.lang.reflect.Method.invoke(Method.java:511)
03-20 21:15:12.646 I/B4A     ( 4991):    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:167)
03-20 21:15:12.646 I/B4A     ( 4991):    ... 14 more
03-20 21:15:12.662 E/AndroidRuntime( 4991): FATAL EXCEPTION: main
03-20 21:15:12.662 E/AndroidRuntime( 4991): java.lang.RuntimeException: Unable to start service appsright.musicnotifier.scheduler@415f1040 with null: java.lang.RuntimeException: java.lang.RuntimeException: Object should first be initialized (Intent).
03-20 21:15:12.662 E/AndroidRuntime( 4991):    at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2603)
03-20 21:15:12.662 E/AndroidRuntime( 4991):    at android.app.ActivityThread.access$2000(ActivityThread.java:141)
03-20 21:15:12.662 E/AndroidRuntime( 4991):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1364)
03-20 21:15:12.662 E/AndroidRuntime( 4991):    at android.os.Handler.dispatchMessage(Handler.java:99)
03-20 21:15:12.662 E/AndroidRuntime( 4991):    at android.os.Looper.loop(Looper.java:137)
03-20 21:15:12.662 E/AndroidRuntime( 4991):    at android.app.ActivityThread.main(ActivityThread.java:5059)
03-20 21:15:12.662 E/AndroidRuntime( 4991):    at java.lang.reflect.Method.invokeNative(Native Method)
03-20 21:15:12.662 E/AndroidRuntime( 4991):    at java.lang.reflect.Method.invoke(Method.java:511)
03-20 21:15:12.662 E/AndroidRuntime( 4991):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:792)
03-20 21:15:12.662 E/AndroidRuntime( 4991):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555)
03-20 21:15:12.662 E/AndroidRuntime( 4991):    at dalvik.system.NativeStart.main(Native Method)
03-20 21:15:12.662 E/AndroidRuntime( 4991): Caused by: java.lang.RuntimeException: java.lang.RuntimeException: Object should first be initialized (Intent).
03-20 21:15:12.662 E/AndroidRuntime( 4991):    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:193)
03-20 21:15:12.662 E/AndroidRuntime( 4991):    at anywheresoftware.b4a.BA.raiseEvent(BA.java:151)
03-20 21:15:12.662 E/AndroidRuntime( 4991):    at appsright.musicnotifier.scheduler.handleStart(scheduler.java:65)
03-20 21:15:12.662 E/AndroidRuntime( 4991):    at appsright.musicnotifier.scheduler.onStartCommand(scheduler.java:50)
03-20 21:15:12.662 E/AndroidRuntime( 4991):    at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2586)
03-20 21:15:12.662 E/AndroidRuntime( 4991):    ... 10 more
03-20 21:15:12.662 E/AndroidRuntime( 4991): Caused by: java.lang.RuntimeException: Object should first be initialized (Intent).
03-20 21:15:12.662 E/AndroidRuntime( 4991):    at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:45)
03-20 21:15:12.662 E/AndroidRuntime( 4991):    at anywheresoftware.b4a.objects.IntentWrapper.HasExtra(IntentWrapper.java:110)
03-20 21:15:12.662 E/AndroidRuntime( 4991):    at appsright.musicnotifier.scheduler._service_start(scheduler.java:1227)
03-20 21:15:12.662 E/AndroidRuntime( 4991):    at java.lang.reflect.Method.invokeNative(Native Method)
03-20 21:15:12.662 E/AndroidRuntime( 4991):    at java.lang.reflect.Method.invoke(Method.java:511)
03-20 21:15:12.662 E/AndroidRuntime( 4991):    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:167)
03-20 21:15:12.662 E/AndroidRuntime( 4991):    ... 14 more
 

JonPM

Well-Known Member
Licensed User
What is Utilities? It looks like this isn't being re-initialized at the start of the service.
 

melamoud

Active Member
Licensed User
Do you know what android versions sticky attribute will work on ?
for some reason this does not happen on my other phones
 
Top