Ah j'ai un peu compris le debug, faut faire resume pour que ca crash, ca boquait tout le temps avant de crasher, voila les lignes rouges du logcat, ca appel d'autres fonctions du services que je n'ai pas cité pour simplifier mais le probleme est le même je pense:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| 06-07 14:13:17.795: ERROR/AndroidRuntime(225): Uncaught handler: thread main exiting due to uncaught exception
06-07 14:13:17.915: ERROR/AndroidRuntime(225): java.lang.RuntimeException: Unable to resume activity {com.kamax.regnum_war_status/com.kamax.regnum_war_status.Regnum_war_status}: java.lang.NullPointerException
06-07 14:13:17.915: ERROR/AndroidRuntime(225): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2851)
06-07 14:13:17.915: ERROR/AndroidRuntime(225): at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2866)
06-07 14:13:17.915: ERROR/AndroidRuntime(225): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2420)
06-07 14:13:17.915: ERROR/AndroidRuntime(225): at android.app.ActivityThread.access$2100(ActivityThread.java:116)
06-07 14:13:17.915: ERROR/AndroidRuntime(225): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
06-07 14:13:17.915: ERROR/AndroidRuntime(225): at android.os.Handler.dispatchMessage(Handler.java:99)
06-07 14:13:17.915: ERROR/AndroidRuntime(225): at android.os.Looper.loop(Looper.java:123)
06-07 14:13:17.915: ERROR/AndroidRuntime(225): at android.app.ActivityThread.main(ActivityThread.java:4203)
06-07 14:13:17.915: ERROR/AndroidRuntime(225): at java.lang.reflect.Method.invokeNative(Native Method)
06-07 14:13:17.915: ERROR/AndroidRuntime(225): at java.lang.reflect.Method.invoke(Method.java:521)
06-07 14:13:17.915: ERROR/AndroidRuntime(225): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
06-07 14:13:17.915: ERROR/AndroidRuntime(225): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
06-07 14:13:17.915: ERROR/AndroidRuntime(225): at dalvik.system.NativeStart.main(Native Method)
06-07 14:13:17.915: ERROR/AndroidRuntime(225): Caused by: java.lang.NullPointerException
06-07 14:13:17.915: ERROR/AndroidRuntime(225): at com.kamax.regnum_war_status.Regnum_war_status.downloadMapText(Regnum_war_status.java:636)
06-07 14:13:17.915: ERROR/AndroidRuntime(225): at com.kamax.regnum_war_status.Regnum_war_status.rechargeMap(Regnum_war_status.java:706)
06-07 14:13:17.915: ERROR/AndroidRuntime(225): at com.kamax.regnum_war_status.Regnum_war_status.onResume(Regnum_war_status.java:451)
06-07 14:13:17.915: ERROR/AndroidRuntime(225): at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1225)
06-07 14:13:17.915: ERROR/AndroidRuntime(225): at android.app.Activity.performResume(Activity.java:3560)
06-07 14:13:17.915: ERROR/AndroidRuntime(225): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2838)
06-07 14:13:17.915: ERROR/AndroidRuntime(225): ... 12 more |
edit: peut etre la facon don't je me connecte au service pose probleme ou n'est pas démarré correctement/fini.
monactivite.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| Imonservice service;
monserviceConnection connection;
class monserviceConnection implements ServiceConnection {
public void onServiceConnected(ComponentName name, IBinder boundService) {
service = Imonservice.Stub.asInterface((IBinder) boundService);
}
public void onServiceDisconnected(ComponentName name) {
service = null;
}
}
private void initService() {
connection = new monserviceConnection();
Intent i = new Intent();
i.setClassName("com.kamax.regnum_war_status",com.kamax.regnum_war_status.monservice.class.getName());
boolean ret = bindService(i, connection, Context.BIND_AUTO_CREATE);
//debugtv.append("ret="+ret+"\n");
}
private void releaseService() {
unbindService(connection);
connection = null;
} |
plus loins dans le même fichier:
1 2 3 4 5 6 7
| /** Called when the activity is first created. */
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
startService(new Intent(this, monservice.class));
initService(); |
edit 2:
Quand je lance service.quelquechose par onResume, eclipse me marque que ca vaut null, par contre si je lance la même chose par un boutton c'est plus null du tout ,j'ai:
service=Imonservice$Stub$Proxy
contre
quand ca marche pas avec onResume
Edit 3: j'ai un peu mieux ciblé le probleme, onServiceConnected n'est pas lancé tant que je ne suis pas sorti de OnResume. J'ai mis un compteur à 2s apres le lancement de l'appli et ça marche comme rustine mais bon...pas tres propre tout ca je pense.
Partager