Il giorno giovedì 18 febbraio 2016 13:10:38 UTC+1, Christian Cortese ha scritto: > > Hello > > i'm doing an app and i have included this code > http://developer.android.com/training/contacts-provider/retrieve-names.html > > but i have a problem...on kitkat it works well, in lollipop i can't see > the menu toolbar and when i click on a contact the app crashes with a > nullpointerexception > *void.android.app.actionbar.setdisplayhomeasupenabled(boolean) etc* > in this portion of code: > > if (Utils.hasHoneycomb()) { > // Enables action bar "up" navigation > getActionBar().setDisplayHomeAsUpEnabled(true); > > > } > > > how can i resolve this?? > > thanks for all > >
this is the exception on Lollipop 02-18 13:41:15.304 31435-31435/todonotes.com.todonotes_buildfinale E/AndroidRuntime: FATAL EXCEPTION: main Process: todonotes.com.todonotes_buildfinale, PID: 31435 java.lang.RuntimeException: Unable to start activity ComponentInfo{todonotes.com.todonotes_buildfinale/todonotes.com.todonotes_buildfinale.ContactDetailActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.app.ActionBar.setDisplayHomeAsUpEnabled(boolean)' on a null object reference at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2378) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2440) at android.app.ActivityThread.access$800(ActivityThread.java:162) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1348) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5422) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:914) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:707) Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.app.ActionBar.setDisplayHomeAsUpEnabled(boolean)' on a null object reference at todonotes.com.todonotes_buildfinale.ContactDetailActivity.onCreate(ContactDetailActivity.java:59) at android.app.Activity.performCreate(Activity.java:6057) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2331) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2440) at android.app.ActivityThread.access$800(ActivityThread.java:162) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1348) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5422) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:914) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:707) -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscr...@googlegroups.com. To post to this group, send email to android-developers@googlegroups.com. Visit this group at https://groups.google.com/group/android-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/android-developers/bbcdc785-f1f8-4708-abdd-3afcd34cc5b1%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.