本文整理匯總了Java中android.app.NotificationManager.INTERRUPTION_FILTER_ALARMS屬性的典型用法代碼示例。如果您正苦於以下問題:Java NotificationManager.INTERRUPTION_FILTER_ALARMS屬性的具體用法?Java NotificationManager.INTERRUPTION_FILTER_ALARMS怎麽用?Java NotificationManager.INTERRUPTION_FILTER_ALARMS使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類android.app.NotificationManager
的用法示例。
在下文中一共展示了NotificationManager.INTERRUPTION_FILTER_ALARMS屬性的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onMessageReceived
@Override
public void onMessageReceived(MessageEvent messageEvent) {
Log.d(TAG, "onMessageReceived: " + messageEvent);
switch (messageEvent.getPath()) {
case PATH_DND:
if (messageEvent.getData().length == 0)
return;
int state = (int) messageEvent.getData()[0];
Log.d(TAG, "Target state: " + state);
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
if (state != NotificationManager.INTERRUPTION_FILTER_ALL)
state = NotificationManager.INTERRUPTION_FILTER_ALARMS;
if (state == (int) notificationManager.getCurrentInterruptionFilter())
return;
if (notificationManager.isNotificationPolicyAccessGranted())
notificationManager.setInterruptionFilter(state);
} else if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Intent intent = new Intent(LGHackService.ACTION_SET_STATE);
intent.putExtra(LGHackService.EXTRA_STATE, (int) messageEvent.getData()[0]);
sendBroadcast(intent);
} else {
AudioManager audioManager = (AudioManager) this.getSystemService(Context.AUDIO_SERVICE);
state = state == 4 ? AudioManager.RINGER_MODE_SILENT : AudioManager.RINGER_MODE_NORMAL;
//INTERRUPTION_FILTER_ALARMS
if (state == audioManager.getRingerMode())
return;
audioManager.setRingerMode(state);
}
return;
case PATH_DND_REGISTER:
if (messageEvent.getData().length == 0)
return;
Intent connectIntent = new Intent(WEAR_CALLBACK_CONNECT);
if (messageEvent.getData().length > 1) {
DataMap config = DataMap.fromByteArray(messageEvent.getData());
connectIntent.putExtra("permission", config.getBoolean("permission"));
}
sendBroadcast(connectIntent);
Log.d(TAG, "Connected broadcast");
return;
case PATH_LOGS:
if (messageEvent.getData().length == 0)
return;
Intent logIntent = new Intent(WEAR_CALLBACK_LOGS);
logIntent.putExtra("log", new String(messageEvent.getData()));
sendBroadcast(logIntent);
Log.d(TAG, "Logs broadcast");
return;
}
}