Android Question Activity.OpenMenu error

tonymonaghan

Member
Licensed User
Longtime User
When run on some android 5 devices my project now gives an error when I use Activity.OpenMenu or when the menu key is pressed. I get the error:-

android.content.res.Resources$NotFoundException: Resource ID #0x0

I have searched through the forums but can't seem to resolve the problem. All the layout files are still there, do I need any additional resources for android 5?

Here is a full listing of the error report.

android.content.res.Resources$NotFoundException: Resource ID #0x0
at android.content.res.Resources.getValue(Resources.java:1343)
at android.content.res.Resources.getDrawable(Resources.java:819)
at android.content.res.Resources.getDrawable(Resources.java:799)
at android.content.Context.getDrawable(Context.java:403)
at com.android.internal.policy.impl.PhoneWindow.openPanel(PhoneWindow.java:789)
at com.android.internal.policy.impl.PhoneWindow.openPanel(PhoneWindow.java:714)
at android.app.Activity.openOptionsMenu(Activity.java:3163)
at anywheresoftware.b4a.objects.ActivityWrapper.OpenMenu(ActivityWrapper.java:229)
at com.ncssoftware.speakingalarmclock.main._pnltime_click(main.java:2206)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:668)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:334)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:244)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:132)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:175)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:171)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:78)
at android.view.View.performClick(View.java:4789)
at android.view.View$PerformClick.run(View.java:19881)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5293)
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:904)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:699)
** Activity (main) Pause, UserClosed = true **


Thanks.
 

tonymonaghan

Member
Licensed User
Longtime User
Problem solved.
I wrote a small program with one menu option and it worked fine. So then after a lot of testing different possibilities found that I didn't have a theme in my manifest, I put in the following line and all was well.

SetApplicationAttribute(android:theme, "@android:style/Theme.Holo")

Thanks for your help.
 
Upvote 0

hasanaydin52

Member
Licensed User
Longtime User
I must use Translucent theme, without title with action bar. Result: Activity.OpenMenu does not run.

Openmenu runs when with title and without actionbar and no translucent theme.
 
Upvote 0

tonymonaghan

Member
Licensed User
Longtime User
I had problems with OpenMenu using the dark material theme with a phone running CyanogenMod 13. I had to use the light theme and it worked OK. Not found a way to use the dark theme yet. Try different themes and see which work.
 
Upvote 0
Top