The following is a popup message I get on an Android Emulator running 1.5 -->
The following is a popup message I get on an Android Emulator running 1.5 -->
The application Android Sample Mobile App (process com.mycompany.mobile.android) has stopped unexpectedly. Please try again.
This occurs when I click on the device's menu button; th开发者_开发知识库e menu comes up with an exit icon...which does the following when selected..
public boolean onOptionsItemSelected(MenuItem item) {
// Handle item selection
switch (item.getItemId()) {
case R.id.exit:
this.finish();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
In other Android versions this code works fine.
Post your stacktrace or LogCat and we can see what's wrong.
My hunch is that it's either calling super out of order for that API level, or that finishing an activity inside of a switch may not be handled correctly, or that that item mightbe a null ref. more info plz.
Android 1.5 is one of the oldest versions (if not the oldest), most if not all handsets have 1.6 or greater. I would not recommend breaking your head on this. Also there are very significant differences between 1.5 to 1.6, the API's are a lot more consistent from 1.6. Not the answer you want, but just my two cents.
Just a piece of advice: it seems like you are adding an exit button to your application.
Beware that it is advised NOT TO add an Exit Button to Android Applications: Is quitting an application frowned upon?
精彩评论