I am trying to show a toast message in my application using the following code.
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle("Do you want to continue?");
alert.setPositiveButton("Continue", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
try{
//This code generates an Activity Not Found exception
}
catch(ActivityNotFoundException e) {
System.out.println("Activity Not Found Exception Raised");
Toast.makeText(getBaseContext(), "Activity Not Found", Toast.LENGTH_LONG).show(); // For the context I tried using getBaseContext, ActivityName.this also
}
}
});
alert.setNegativeButton("Cancel",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
}
});
alert.show();
But this message is being shown only on few devices. I've tested this code on HTC One X having Android version 4.2.2 which is working.
The same code if I test on Micromax A63 which is also having Android 4.2.2, but it doesn't work on it.
I've searched over Internet for this kind of errors and they are mostly telling about the app notification disabling option in the settings menu. But my application notification are not disabled.
EDIT
I'm doing it inside an AlertDialog
Can someone help me solve this issue.
In case you haven't figured this out yet, make sure you haven't disabled notifications for the application in question; this also disables toasts.