Мое приложение делает одноразовые тревоги. Когда будильник погаснет, появляется уведомление, и телефон вибрирует. Отображается уведомление, и виабратор работает нормально.Деактивировать вибратор в уже установленных уведомлениях
В настройках приложения я хочу разрешить пользователю деактивировать виабратор в уже установленных уведомлениях. 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