Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@Sankame
Last active October 6, 2017 15:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sankame/9ec48534fad7d8663305f6d9681128b0 to your computer and use it in GitHub Desktop.
Save Sankame/9ec48534fad7d8663305f6d9681128b0 to your computer and use it in GitHub Desktop.
/**
* メッセージ表示
*/
private void showMessage(){
final String KEY_OF_PREFERENCES = "KEY_OF_PREFERENCES";
final SharedPreferences preferences = getPreferences(MODE_PRIVATE);
boolean showMessage = preferences.getBoolean(KEY_OF_PREFERENCES, true);
if(showMessage) {
new AlertDialog.Builder(MainActivity.this)
.setMessage("ユーザーへのメッセージを表示")
.setPositiveButton("OK", null)
.setNegativeButton("次回から表示しない", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean(KEY_OF_PREFERENCES, false);
editor.commit();
}
})
.show();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment