How can I help you if I have no idea what your code is doing? It might help to see the lines of the code in the exception. I certainly can't see how this has anything to do with being in a subclass -- like I said, you are calling this on a Context that isn't initialized, such as what would happen if you call on an Activity before its onCreate() is called.
On Sat, May 16, 2009 at 3:34 AM, mscwd01 <[email protected]> wrote: > > This problem is baffling me, I cannot work out why a call to > startActivity() from the subclass of the running Activity causes this > error. If I call startActivity() from the Activity itself, not the > subclass of the Activity, it works fine. > > Any ideas? I've spent too long on this problem now ;) > > On May 15, 11:54 pm, mscwd01 <[email protected]> wrote: > > Here's the complete stack trace: > > > > 05-15 23:51:58.278: ERROR/AndroidRuntime(731): Uncaught handler: > > thread main exiting due to uncaught exception > > 05-15 23:51:58.340: ERROR/AndroidRuntime(731): > > java.lang.NullPointerException > > 05-15 23:51:58.340: ERROR/AndroidRuntime(731): at > > android.content.ContextWrapper.getPackageName(ContextWrapper.java:119) > > 05-15 23:51:58.340: ERROR/AndroidRuntime(731): at > > android.content.ComponentName.<init>(ComponentName.java:74) > > 05-15 23:51:58.340: ERROR/AndroidRuntime(731): at > > android.content.Intent.<init>(Intent.java:2093) > > 05-15 23:51:58.340: ERROR/AndroidRuntime(731): at > > org.geotact.util.MenuListFactory.menuItemClicked(MenuListFactory.java: > > 52) > > 05-15 23:51:58.340: ERROR/AndroidRuntime(731): at > > org.geotact.util.MenuListFactory.access$1(MenuListFactory.java:48) > > 05-15 23:51:58.340: ERROR/AndroidRuntime(731): at > > org.geotact.util.MenuListFactory$MenuClickListener.onItemClick > > (MenuListFactory.java:69) > > 05-15 23:51:58.340: ERROR/AndroidRuntime(731): at > > android.widget.AdapterView.performItemClick(AdapterView.java:283) > > 05-15 23:51:58.340: ERROR/AndroidRuntime(731): at > > android.widget.ListView.performItemClick(ListView.java:3132) > > 05-15 23:51:58.340: ERROR/AndroidRuntime(731): at > > android.widget.AbsListView$PerformClick.run(AbsListView.java:1620) > > 05-15 23:51:58.340: ERROR/AndroidRuntime(731): at > > android.os.Handler.handleCallback(Handler.java:587) > > 05-15 23:51:58.340: ERROR/AndroidRuntime(731): at > > android.os.Handler.dispatchMessage(Handler.java:92) > > 05-15 23:51:58.340: ERROR/AndroidRuntime(731): at > > android.os.Looper.loop(Looper.java:123) > > 05-15 23:51:58.340: ERROR/AndroidRuntime(731): at > > android.app.ActivityThread.main(ActivityThread.java:3948) > > 05-15 23:51:58.340: ERROR/AndroidRuntime(731): at > > java.lang.reflect.Method.invokeNative(Native Method) > > 05-15 23:51:58.340: ERROR/AndroidRuntime(731): at > > java.lang.reflect.Method.invoke(Method.java:521) > > 05-15 23:51:58.340: ERROR/AndroidRuntime(731): at > > com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run > > (ZygoteInit.java:782) > > 05-15 23:51:58.340: ERROR/AndroidRuntime(731): at > > com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540) > > 05-15 23:51:58.340: ERROR/AndroidRuntime(731): at > > dalvik.system.NativeStart.main(Native Method) > > > > On May 15, 6:12 pm, Dianne Hackborn <[email protected]> wrote: > > > > > Please include the complete stack crawl. > > > > > On Fri, May 15, 2009 at 9:14 AM, mscwd01 <[email protected]> wrote: > > > > > > Hey, > > > > > > I have a Activity and I have a class which extends this Activity. In > > > > this subclass I call: > > > > > > startActivity(new Intent(this, CameraView.class)) > > > > > > Which should start the "CameraView" Activity. However, I always get > > > > this error: > > > > > > ERROR/AndroidRuntime(876): java.lang.NullPointerException > > > > ERROR/AndroidRuntime(876): at > > > > > android.content.ContextWrapper.getPackageName(ContextWrapper.java:119) > > > > ERROR/AndroidRuntime(876): at > android.content.ComponentName.<init> > > > > (ComponentName.java:74) > > > > ERROR/AndroidRuntime(876): at android.content.Intent.<init> > > > > (Intent.java:2093) > > > > > > If it makes any difference the subclass creates a ListView and when a > > > > row of the ListView is clicked it calls startActivity(); > > > > > > Any help is appreciated! Thanks > > > > > -- > > > Dianne Hackborn > > > Android framework engineer > > > [email protected] > > > > > Note: please don't send private questions to me, as I don't have time > to > > > provide private support, and so won't reply to such e-mails. All such > > > questions should be posted on public forums, where I and others can see > and > > > answer them. > > > -- Dianne Hackborn Android framework engineer [email protected] Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. 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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

