Policy policy = new Policy();
policy.setName("Kiosk Mode Policy");
policy.setDisableStatusBar(true);
policy.setDisablePowerButton(true);
policy.setDisableVolumeButtons(true);
policy.setDisableSettings(true);
policy.setDisableStatusIcons(true);
policy.setDisableWiFi(true);
policy.setDisableBluetooth(true);
policy.setDisableCamera(true);
policy.setDisableNFC(true);
policy.setDisableLocationServices(true);
policy.setDisableScreenCapture(true);
policy.setDisableFactoryReset(true);
policy.setDisableSafeBoot(true);
policy.setDisablePasswordRequirement(true);
policy.setDisablePasswordExpiration(true);
policy.setDisableLogoutOnScreenOff(true);
policy.setDisableSound(true); // This line disables all sounds and vibrations
policy.setDisableVibration(true);
AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
audioManager.setStreamMute(AudioManager.STREAM_NOTIFICATION, true);
当需要恢复通知声音时,将第二个参数设置为 false 即可
audioManager.setStreamMute(AudioManager.STREAM_NOTIFICATION, false);