Below is my alertDialog that I am using to display information to the user.
final AlertDialog.Builder alertDialog = new AlertDialog.Builder(this);
alertDialog.show();
alertDialog.setIcon(R.drawable.ic_launcher);
alertDialog.setTitle("Title");
alertDialog.setMessage("dialog");
alertDialog.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
Now, I have been doing research and looking around on stackoverflow to see how can I get this dialog to display once and I found something that could help. I had studied this code and broke it down to the limits of my knowledge in this area but I can not seem to figure out what the problems are.
final SharedPreferences settings = getSharedPreferences("pref_name", 0);
boolean disappear = settings.getBoolean("installed", false);
if (disappear == false) {
final AlertDialog.Builder alertDialog = new AlertDialog.Builder(this);
AlertDialog alert = alertDialog .create();
alertDialog.setIcon(R.drawable.ic_launcher);
alertDialog.setTitle("Title");
alertDialog.setMessage("dialog");
alertDialog.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
settings.edit().putBoolean("installed", true).commit();
}
alertDialog.show();
The problem is that when I launch this application on an emulator my dialog doesn't show and nothing in my application respond to anything, really similar to this guy problem in this link that I found Shared Prefence for alert dialog is making my application non responsive I have to tried to break down this code and try to figure out why this is happening but Im limit in my knowledge in this area. So can somebody help solve this.
10-13 03:10:37.496: E/AndroidRuntime(761): FATAL EXCEPTION: main
10-13 03:10:37.496: E/AndroidRuntime(761): android.app.SuperNotCalledException: Activity {com.theproblemsolver/com.theproblemsolver.MainActivity} did not call through to super.onPause()
10-13 03:10:37.496: E/AndroidRuntime(761): at android.app.Activity.performPause(Activity.java:5210)
10-13 03:10:37.496: E/AndroidRuntime(761): at android.app.Instrumentation.callActivityOnPause(Instrumentation.java:1226)
10-13 03:10:37.496: E/AndroidRuntime(761): at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3002)
10-13 03:10:37.496: E/AndroidRuntime(761): at android.app.ActivityThread.performPauseActivity(ActivityThread.java:2971)
10-13 03:10:37.496: E/AndroidRuntime(761): at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:2949)
10-13 03:10:37.496: E/AndroidRuntime(761): at android.app.ActivityThread.access$800(ActivityThread.java:141)
10-13 03:10:37.496: E/AndroidRuntime(761): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1245)
10-13 03:10:37.496: E/AndroidRuntime(761): at android.os.Handler.dispatchMessage(Handler.java:99)
10-13 03:10:37.496: E/AndroidRuntime(761): at android.os.Looper.loop(Looper.java:137)
10-13 03:10:37.496: E/AndroidRuntime(761): at android.app.ActivityThread.main(ActivityThread.java:5041)
10-13 03:10:37.496: E/AndroidRuntime(761): at java.lang.reflect.Method.invokeNative(Native Method)
10-13 03:10:37.496: E/AndroidRuntime(761): at java.lang.reflect.Method.invoke(Method.java:511)
10-13 03:10:37.496: E/AndroidRuntime(761): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
10-13 03:10:37.496: E/AndroidRuntime(761): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
10-13 03:10:37.496: E/AndroidRuntime(761): at dalvik.system.NativeStart.main(Native Method)