I get an exception when trying to display a dialog in Android. My AlertDialog is called from FragmentActivity with the following code:
public static void displayShare(){ // show share options CharSequence selections[] = new CharSequence[] {"Email", "SMS", "Tweet", "Phone Call", "Cancel"}; final AlertDialog.Builder builder = new AlertDialog.Builder(CommonVariables.mContext); builder.setTitle("Share your location via..."); builder.setItems(selections, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { switch(which){ case 0: // Email callEmailMethod(); break; case 1: // SMS callSMSMethod(); break; case 2: // Tweet callTwitterMethod(); break; case 3: // Phone Call callNumberMethod(); break; case 4: dialog.cancel(); break; } } }); builder.show(); }
The following error was received in the line: builder.show ();
FATAL EXCEPTION: main Process: com.au.ewn.melbwater, PID: 2839 android.content.res.Resources$NotFoundException: Resource ID
I tried everything (except for the correct solution, it seems). Any help is appreciated, thanks.
Note. CommonVariables.mContext is the context of the FragmentActivity function and is not null: CommonVariables.mContext = FragmentAct.this;
android android-fragments android-alertdialog
Nickmccomb
source share