アラームを設定するには、添付のコードを使用します。これは、1 つのことを除いて正常に動作します。電話がオフになっていて通知が始まった場合、目覚まし時計のように音量ボタンを押しても通知を止めることはできません。
これがどのように処理されているか、またはどこで見つけられるかを知っている人はいますか?
どうもありがとうございました!
public class OneShotAlarm extends BroadcastReceiver {
private static final int NOTIFICATION_ID = 0;
@Override
public void onReceive(Context context, Intent intent)
{
NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(R.drawable.icon, "bla", System.currentTimeMillis());
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, new Intent(context, Personal.class), 0);
notification.setLatestEventInfo(context, "bla", "blabla", contentIntent);
notification.flags = Notification.FLAG_ONLY_ALERT_ONCE;
notification.flags = Notification.FLAG_AUTO_CANCEL;
notification.sound = (Uri) intent.getParcelableExtra("notificationTone");
if (intent.getBooleanExtra("vibrationEnabled", true)){
notification.vibrate = (long[]) intent.getExtras().get("vibrationPatern");
}
manager.notify(NOTIFICATION_ID, notification);
}
}