Closed safinahmed closed 11 years ago
data.ServiceRunning was returning false the first time around for some reason, but now it's ok
@safinahmed I think I'm facing the same problem as you. Could you tell me how you solved it?
Thx :)
Hey greips, I would, but all that happened was that I ran it once in debug mode (so I could pinpoint the error) and it started working from that point on The first time around data.ServiceRunning was returning false as I mentioned (not sure why) After that I tried debugging again and data.ServiceRunning was already returning true and everything started going smoothly
Sorry I couldn't be more helpful and good luck
Maybe the service started bit to early in your scripts? (before Phonegap was fully loaded?). Not sure, just guessing here :).
2013/8/20 safinahmed notifications@github.com
Hey greips, I would, but all that happened was that I ran it once in debug mode (so I could pinpoint the error) and it started working from that point on The first time around data.ServiceRunning was returning false as I mentioned (not sure why) After that I tried debugging again and data.ServiceRunning was already returning true and everything started going smoothly
Sorry I couldn't be more helpful and good luck
— Reply to this email directly or view it on GitHubhttps://github.com/Red-Folder/Cordova-Plugin-BackgroundService/issues/10#issuecomment-22943023 .
www.teusink.org www.droidpapers.org
@safinahmed ok... i thought you just hack into the code.
@teusinkorg nice to see you here as well :P I put my code as a response in your opened issue for 2.8, and there you can see this sequence: 08-19 18:50:14.679: D/BackgroundServicePluginLogic(27704): Check if the service is running? 08-19 18:50:14.684: D/BackgroundServicePluginLogic(27704): Service is running? 08-19 18:50:14.699: D/BackgroundServicePluginLogic(27704): Exception - null 08-19 18:50:14.719: W/dalvikvm(27704): threadid=23: thread exiting with uncaught exception (group=0x4123a930)
so I guess the problem is related to the answer to the question "Service is running?" It might return null or something unexpected and then it crashes...
@greips Hi :)
It fails on this command: service.isServiceRunning()
This is the function: private boolean isServiceRunning() { boolean result = false;
// Return Plugin with ServiceRunning true/ false ActivityManager manager = (ActivityManager)this.mContext.getSystemService( Context.ACTIVITY_SERVICE); for (RunningServiceInfo service : manager.getRunningServices(Integer. MAX_VALUE)) { if (this.mServiceName.equals(service.service.getClassName())) { result = true; } } return result; } Source: https://github.com/Red-Folder/Cordova-Plugin-BackgroundService-Source/blob/e904dfab1dd6ac7ba1f68a8809509c3758cd176a/src/com/red_folder/phonegap/plugin/backgroundservice/BackgroundServicePluginLogic.java
It is strange that the function would return null. As it boolean is initialized with false. So I guess that it has to do something with either ActivityManager or RunningServiceInfo (that is returning null), so it fails within the function. As I do not suffer from this error I cannot test it out.
Perhaps the developer knows.
2013/8/20 greips notifications@github.com
@safinahmed https://github.com/safinahmed ok... i thought you just hack into the code.
@teusinkorg https://github.com/teusinkorg nice to see you here as well :P I put my code as a response in your opened issue for 2.8, and there you can see this sequence: 08-19 18:50:14.679: D/BackgroundServicePluginLogic(27704): Check if the service is running? 08-19 18:50:14.684: D/BackgroundServicePluginLogic(27704): Service is running? 08-19 18:50:14.699: D/BackgroundServicePluginLogic(27704): Exception - null 08-19 18:50:14.719: W/dalvikvm(27704): threadid=23: thread exiting with uncaught exception (group=0x4123a930)
so I guess the problem is related to the answer to the question "Service is running?" It might return null or something unexpected and then it crashes...
— Reply to this email directly or view it on GitHubhttps://github.com/Red-Folder/Cordova-Plugin-BackgroundService/issues/10#issuecomment-22943423 .
www.teusink.org www.droidpapers.org
@teusinkorg Actually i think it fails at line 151:
Log.d(TAG, "Service is running?");
EDITED:
Actually, looking at the code it might fail at the startService() when the bind is failed... That's the only difference I can see.
It's the same issue as https://github.com/Red-Folder/Cordova-Plugin-BackgroundService/issues/7
I'm putting comments on that issue at it's got the logcat
I have successfully implemented you plugin on Android 2.7 using PhoneGap 2.7.0, but when testing in version 4.1 and 4.2 I get the following error
W/dalvikvm(1074): threadid=17: thread exiting with uncaught exception (group=0x40a71930)
Do you have any idea how I might fix this ?
I was able to pinpoint it to this call in the JS side app.service.enableTimer But on the Java side, I have logging statement everywhere, and it doesn't show anything
Thanks in advance