I created a new project.. There is just one java file which is
Try.java :
public class Try extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button b = (Button)findViewById(R.id.btn);
b.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
openOptionsMenu();
}
});
}
public boolean onCreateOptionsMenu(Menu menu) {
menu.add(0, 1, 0, "New Game");
menu.add(0, 2, 0, "Quit");
return true;
}
/* Handles item selections */
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case 1:
return true;
case 2:
return true;
}
return false;
}
}
And got as usual this stack trace. I am running on android 1.5
02-24 19:04:22.858: WARN/dalvikvm(30458): threadid=3: thread exiting
with uncaught exception (group=0x40010e70)
02-24 19:04:22.858: ERROR/AndroidRuntime(30458): Uncaught handler:
thread main exiting due to uncaught exception
02-24 19:04:22.949: ERROR/AndroidRuntime(30458):
java.lang.NullPointerException
02-24 19:04:22.949: ERROR/AndroidRuntime(30458): at
com.android.internal.policy.impl.PhoneWindow.openPanel(PhoneWindow.java:
553)
02-24 19:04:22.949: ERROR/AndroidRuntime(30458): at
com.android.internal.policy.impl.PhoneWindow.openPanel(PhoneWindow.java:
542)
02-24 19:04:22.949: ERROR/AndroidRuntime(30458): at
android.app.Activity.openOptionsMenu(Activity.java:2220)
02-24 19:04:22.949: ERROR/AndroidRuntime(30458): at com.test.Try
$1.onClick(Try.java:22)
02-24 19:04:22.949: ERROR/AndroidRuntime(30458): at
android.view.View.performClick(View.java:2179)
02-24 19:04:22.949: ERROR/AndroidRuntime(30458): at
android.view.View.onTouchEvent(View.java:3828)
02-24 19:04:22.949: ERROR/AndroidRuntime(30458): at
android.widget.TextView.onTouchEvent(TextView.java:6362)
02-24 19:04:22.949: ERROR/AndroidRuntime(30458): at
android.view.View.dispatchTouchEvent(View.java:3368)
02-24 19:04:22.949: ERROR/AndroidRuntime(30458): at
android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:863)
02-24 19:04:22.949: ERROR/AndroidRuntime(30458): at
android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:863)
02-24 19:04:22.949: ERROR/AndroidRuntime(30458): at
android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:863)
02-24 19:04:22.949: ERROR/AndroidRuntime(30458): at
android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:863)
02-24 19:04:22.949: ERROR/AndroidRuntime(30458): at
com.android.internal.policy.impl.PhoneWindow
$DecorView.superDispatchTouchEvent(PhoneWindow.java:1885)
02-24 19:04:22.949: ERROR/AndroidRuntime(30458): at
com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:
1324)
02-24 19:04:22.949: ERROR/AndroidRuntime(30458): at
android.app.Activity.dispatchTouchEvent(Activity.java:1993)
02-24 19:04:22.949: ERROR/AndroidRuntime(30458): at
com.android.internal.policy.impl.PhoneWindow
$DecorView.dispatchTouchEvent(PhoneWindow.java:1869)
02-24 19:04:22.949: ERROR/AndroidRuntime(30458): at
android.view.ViewRoot.handleMessage(ViewRoot.java:1525)
02-24 19:04:22.949: ERROR/AndroidRuntime(30458): at
android.os.Handler.dispatchMessage(Handler.java:99)
02-24 19:04:22.949: ERROR/AndroidRuntime(30458): at
android.os.Looper.loop(Looper.java:123)
02-24 19:04:22.949: ERROR/AndroidRuntime(30458): at
android.app.ActivityThread.main(ActivityThread.java:3948)
02-24 19:04:22.949: ERROR/AndroidRuntime(30458): at
java.lang.reflect.Method.invokeNative(Native Method)
02-24 19:04:22.949: ERROR/AndroidRuntime(30458): at
java.lang.reflect.Method.invoke(Method.java:521)
02-24 19:04:22.949: ERROR/AndroidRuntime(30458): at
com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:782)
02-24 19:04:22.949: ERROR/AndroidRuntime(30458): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
02-24 19:04:22.949: ERROR/AndroidRuntime(30458): at
dalvik.system.NativeStart.main(Native Method)
On 25 fév, 10:24, skink <[email protected]> wrote:
> On Feb 25, 9:56 am, Houcem Berrayana <[email protected]>
> wrote:
>
>
>
>
>
> > Hi skink,
>
> > I tryied first of running in another thread diferent than UI thread
> > but it didn't work also.
>
> > this is my stacktrace:
>
> > 02-24 18:09:10.309: ERROR/AndroidRuntime(22919): Uncaught handler:
> > thread main exiting due to uncaught exception
> > 02-24 18:09:10.328: ERROR/AndroidRuntime(22919):
> > java.lang.NullPointerException
> > 02-24 18:09:10.328: ERROR/AndroidRuntime(22919): at
> > com.android.internal.policy.impl.PhoneWindow.openPanel(PhoneWindow.java:
> > 553)
> > 02-24 18:09:10.328: ERROR/AndroidRuntime(22919): at
> > com.android.internal.policy.impl.PhoneWindow.openPanel(PhoneWindow.java:
> > 542)
> > 02-24 18:09:10.328: ERROR/AndroidRuntime(22919): at
> > android.app.Activity.openOptionsMenu(Activity.java:2220)
> > 02-24 18:09:10.328: ERROR/AndroidRuntime(22919): at
> > com.intl.mediaplayer.app.view.MediaPlayerControlsManager
> > $7$1.run(MediaPlayerControlsManager.java:152)
> > 02-24 18:09:10.328: ERROR/AndroidRuntime(22919): at
> > android.os.Handler.handleCallback(Handler.java:587)
> > 02-24 18:09:10.328: ERROR/AndroidRuntime(22919): at
> > android.os.Handler.dispatchMessage(Handler.java:92)
> > 02-24 18:09:10.328: ERROR/AndroidRuntime(22919): at
> > android.os.Looper.loop(Looper.java:123)
> > 02-24 18:09:10.328: ERROR/AndroidRuntime(22919): at
> > android.app.ActivityThread.main(ActivityThread.java:3948)
> > 02-24 18:09:10.328: ERROR/AndroidRuntime(22919): at
> > java.lang.reflect.Method.invokeNative(Native Method)
> > 02-24 18:09:10.328: ERROR/AndroidRuntime(22919): at
> > java.lang.reflect.Method.invoke(Method.java:521)
> > 02-24 18:09:10.328: ERROR/AndroidRuntime(22919): at
> > com.android.internal.os.ZygoteInit
> > $MethodAndArgsCaller.run(ZygoteInit.java:782)
> > 02-24 18:09:10.328: ERROR/AndroidRuntime(22919): at
> > com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
> > 02-24 18:09:10.328: ERROR/AndroidRuntime(22919): at
> > dalvik.system.NativeStart.main(Native Method)
>
> i see:
> com.intl.mediaplayer.app.view.MediaPlayerControlsManager
>
> > $7$1.run(MediaPlayerControlsManager.java:152)
>
> is it yours? if so when it is called?
>
> i'd start by simple things: create Button and in its OnClickListener
> try to open menu
>
> if it works, try to figure out whats wrong in your current code, maybe
> you try to open too early when things are not setup?
>
> pskink
--
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