我在有铃声的应用程序中有共享偏好..
我想禁用通知短信和彩信以及来自应用程序的通知,例如警报通知
<?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();
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)