How can I make my dialog appear only once after my Android app is installed on the device?
yes, new DialogInterface. OnClickListener() { public void onClick(DialogInterface dialog, int which) { // continue with delete Intent intent = new Intent(MainActivity. this, WebActivity. class); startActivity(intent); } }) .
Overriding onCreateView() will let you show a Fragment as dialog and you can make the Title text customized. On the other hand, overriding onCreateDialog(), you can again show a fragment as dialog and here you can customize the entire dialog fragment. Means, you can inflate any view to show as dialog.
setTitle(CharSequence title)AlertDialog alertDialog = alertDialogBuilder. create(); alertDialog. show(); This will create the alert dialog and will show it on the screen.
Use SharedPreference to store the firstrun
value, and check in your launching activity against that value. If the value is set, then no need to display the dialog. If else, display the dialog and save the firstrun
flag in SharedPreference.
ex (in your launching activity):
public void onCreate(){
boolean firstrun = getSharedPreferences("PREFERENCE", MODE_PRIVATE).getBoolean("firstrun", true);
if (firstrun){
//... Display the dialog message here ...
// Save the state
getSharedPreferences("PREFERENCE", MODE_PRIVATE)
.edit()
.putBoolean("firstrun", false)
.commit();
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With