You are probably doing stuff in your constructor. Don't do that, do your initialization in onCreate().
On Sat, Dec 13, 2008 at 4:09 AM, Urig <gimelsht...@gmail.com> wrote: > > Hi everybody, > > I need help :) > > I have an Activity which tries to start a Service (in the same > process). > It never succeeds... I recieve the following NullPointerException > > 12-13 11:39:06.158: ERROR/AndroidRuntime(324): Uncaught handler: > thread main exiting due to uncaught exception > 12-13 11:39:06.178: ERROR/AndroidRuntime(324): > java.lang.RuntimeException: Unable to instantiate service > com.ex.LocalService: java.lang.NullPointerException > 12-13 11:39:06.178: ERROR/AndroidRuntime(324): at > android.app.ActivityThread.handleCreateService(ActivityThread.java: > 2321) > 12-13 11:39:06.178: ERROR/AndroidRuntime(324): at > android.app.ActivityThread.access$2800(ActivityThread.java:112) > 12-13 11:39:06.178: ERROR/AndroidRuntime(324): at > android.app.ActivityThread$H.handleMessage(ActivityThread.java:1631) > 12-13 11:39:06.178: ERROR/AndroidRuntime(324): at > android.os.Handler.dispatchMessage(Handler.java:88) > 12-13 11:39:06.178: ERROR/AndroidRuntime(324): at > android.os.Looper.loop(Looper.java:123) > 12-13 11:39:06.178: ERROR/AndroidRuntime(324): at > android.app.ActivityThread.main(ActivityThread.java:3742) > 12-13 11:39:06.178: ERROR/AndroidRuntime(324): at > java.lang.reflect.Method.invokeNative(Native Method) > 12-13 11:39:06.178: ERROR/AndroidRuntime(324): at > java.lang.reflect.Method.invoke(Method.java:515) > 12-13 11:39:06.178: ERROR/AndroidRuntime(324): at > com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run > (ZygoteInit.java:739) > 12-13 11:39:06.178: ERROR/AndroidRuntime(324): at > com.android.internal.os.ZygoteInit.main(ZygoteInit.java:497) > 12-13 11:39:06.178: ERROR/AndroidRuntime(324): at > dalvik.system.NativeStart.main(Native Method) > 12-13 11:39:06.178: ERROR/AndroidRuntime(324): Caused by: > java.lang.NullPointerException > 12-13 11:39:06.178: ERROR/AndroidRuntime(324): at > android.content.ContextWrapper.getSystemService(ContextWrapper.java: > 323) > 12-13 11:39:06.178: ERROR/AndroidRuntime(324): at > com.ex.LocalService.<init>(LocalService.java:47) > 12-13 11:39:06.178: ERROR/AndroidRuntime(324): at > java.lang.Class.newInstance(Native Method) > 12-13 11:39:06.178: ERROR/AndroidRuntime(324): at > android.app.ActivityThread.handleCreateService(ActivityThread.java: > 2318) > 12-13 11:39:06.178: ERROR/AndroidRuntime(324): ... 10 more > > My onCreate method only calls the parent's onCreate..... > > the service is being started in the following way: > > startService(new Intent(MyActivity.this, LocalService.class)); > > Any suggestions/ideas will make me very glad.... > > Thanks in advance.... > > > > -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---