Last active
October 6, 2017 15:42
-
-
Save Sankame/9ec48534fad7d8663305f6d9681128b0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* メッセージ表示 | |
*/ | |
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