I have 2 activities in my app, in the second one I have the code to run when the "about" android action bar icon is clicked. In the first activity I have the same action bar menu items and I want to call this "about" method again, however when I click that, I have null Pointer exception. Anyone help ?
this is the method defined in the second activity - JokeDetailsActivity
public void aboutMe(){
AlertDialog.Builder dialog = new AlertDialog.Builder(JokeDetailsActivity.this);
dialog.setTitle("About");
dialog.setMessage("Hello! I'm ..., the creator of this application."
+"If there is any bug found please freely e-mail me. "+
"\n ...."
);
dialog.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
dialog.show();
}
when I call it in the first activity
case R.id.action_about:
JokeDetailsActivity jd = new JokeDetailsActivity();
jd.aboutMe();
return true;
}
thats the error I'm getting
09-12 20:11:42.748: E/AndroidRuntime(1032): FATAL EXCEPTION: main
09-12 20:11:42.748: E/AndroidRuntime(1032): java.lang.NullPointerException
09-12 20:11:42.748: E/AndroidRuntime(1032): at android.content.ContextWrapper.getApplicationInfo(ContextWrapper.java:140)
09-12 20:11:42.748: E/AndroidRuntime(1032): at android.view.ContextThemeWrapper.getTheme(ContextThemeWrapper.java:103)
09-12 20:11:42.748: E/AndroidRuntime(1032): at android.app.AlertDialog.resolveDialogTheme(AlertDialog.java:143)
09-12 20:11:42.748: E/AndroidRuntime(1032): at android.app.AlertDialog$Builder.<init>(AlertDialog.java:360)
09-12 20:11:42.748: E/AndroidRuntime(1032): at ie.myjokes.JokeDetailsActivity.aboutMe(JokeDetailsActivity.java:293)
09-12 20:11:42.748: E/AndroidRuntime(1032): at ie.myjokes.CategoryActivity.onOptionsItemSelected(CategoryActivity.java:140)
09-12 20:11:42.748: E/AndroidRuntime(1032): at android.app.Activity.onMenuItemSelected(Activity.java:2548)