[英]Disable Dialog Notification in Shared Preference in android
i have Shared preference in my application that has Ringtone .. 我在具有铃声..的应用程序中具有共享首选项
i wanna to put Disable Notification SMS and MMS and notification from the app like alarm notification 我想将“禁用通知” 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>
This is one of my dialog notification code: 这是我的对话框通知代码之一:
//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();
}
});
}
i try to run it, but when i try with alarm notification it did not work 我尝试运行它,但是当我尝试使用警报通知时,它不起作用
SharedPreferences sharedPreferences = this.getPreferences(MODE_PRIVATE);
boolean hideNotification = sharedPreferences.getBoolean("checkbox", false);
if(!hideNotification)
alertDialog.show();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.