我在开发者控制台中收到了以下堆栈跟踪作为崩溃报告。 有什么我可以做的吗? 我没有想法从哪里开始寻找问题。
java.lang.RuntimeException: Unable to resume activity {android/com.android.internal.app.ChooserActivity}: java.lang.NullPointerException
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2581)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2609)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1240)
at android.os.Handler.disp atchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4803)
at java.lang.reflect.Method.invokeN ative(N ative Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
at dalvik.system.N ativeStart.main(N ative Method)
Caused by: java.lang.NullPointerException
at com.android.internal.app.ResolverActivity$ResolveListAdapter.handlePackagesChanged(ResolverActivity.java:419)
at com.android.internal.app.ResolverActivity.onRestart(ResolverActivity.java:220)
at android.app.Instrument ation.callActivityOnRestart(Instrument ation.java:1173)
at android.app.Activity.performRestart(Activity.java:5063)
at android.app.Activity.performResume(Activity.java:5074)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2571)
... 10 more
修改
以下是代码:
不幸的是,用户没有在崩溃发生时添加消息。
public class MainActivity extends PreferenceActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
InAppHelper.init(); // uses Helper and Logger
addPreferencesFromResource(R.xml.settings);
setContentView(R.layout.preferences_layout);
if (PreferenceHelper.isShowDialogOnStartup()) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.popup_title);
builder.setMessage(R.string.popup_text);
builder.setPositiveButton(R.string.popup_button, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
builder.create().show();
PreferenceHelper.setShowDialogOnStartup(false);
}
}
@Override
protected void onDestroy() {
super.onDestroy();
InAppHelper.dispose();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
Intent intent;
switch (item.getItemId()) {
case R.id.menuContactUs:
intent = new Intent(Intent.ACTION_SEND);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
...
intent.setType("ext/plain");
startActivity(Intent.createChooser(intent, "Email:"));
break;
case R.id.menuRate:
intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("market://details?id=" + getPackageName()));
startActivity(intent);
break;
default:
return super.onOptionsItemSelected(item);
}
return true;
}
}