[英]Disable Dialog Notification in Shared Preference in android
我在具有鈴聲..的應用程序中具有共享首選項
我想將“禁用通知” SMS和MMS以及來自應用程序的通知(例如警報通知)
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<CheckBoxPreference
android:title="Disable Notification"
android:defaultValue="true"
android:key="checkbox"
android:summary="Check the Box"/>
</PreferenceScreen>
這是我的對話框通知代碼之一:
//Alert Code
final AlertDialog alertDialog = new AlertDialog.Builder(this).create();
alertDialog.setTitle("Reset...");
alertDialog.setMessage("Are you sure?");
Alert.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// here you can add functions
}
});
alertDialog.setIcon(android.R.drawable.ic_dialog_alert);
alertDialog.show();
}
});
}
我嘗試運行它,但是當我嘗試使用警報通知時,它不起作用
SharedPreferences sharedPreferences = this.getPreferences(MODE_PRIVATE);
boolean hideNotification = sharedPreferences.getBoolean("checkbox", false);
if(!hideNotification)
alertDialog.show();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.