0
我的應用正在發出一次性警報。當鬧鈴響起時,通知會顯示,手機正在振動。通知顯示,並且viabrator工作正常。在已設置的通知中關閉振動器
在應用程序設置中,我想允許用戶在已設置的通知中禁用viabrator。 Settings
有沒有人有這方面的很好的解決方案。一個解決方案,將允許我添加一些代碼到圖片中顯示的按鈕onclick。
// THX
public class AlarmReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
System.out.println("Broadcast receiver: " + context + intent);
PendingIntent pIntent = PendingIntent.getActivity(context, 0, new Intent(context, MainActivity.class), 0);
// Build notification
Notification noti = new Notification.Builder(context)
.setContentTitle("13:00" + " Bla Bla Bla")
.setContentText("You have " + 0 + " Bla Bla.")
.setSmallIcon(R.drawable.helpicon)
.setContentIntent(pIntent)
.setVibrate(new long[] { 0, 1000, 1000, 1000, 1000 })
.addAction(R.drawable.ic_add_alert_black_24dp, "Postpone", pIntent)
.addAction(R.drawable.ic_close_black_24dp, "Cancel", pIntent)
.addAction(R.drawable.ic_check_black_24dp, "Intake", pIntent).build();
NotificationManager notificationManager = (NotificationManager) context.getSystemService(NOTIFICATION_SERVICE);
// hide the notification after its selected
noti.flags |= Notification.FLAG_AUTO_CANCEL;
notificationManager.notify(0, noti);
}
}
很酷,我會試試看。 – TheDave