我使用随附的代码设置警报。这工作正常,除了一件事。如果手机关闭并且通知开始,您无法像按闹钟那样按音量按钮来停止它。
有谁知道这是如何处理的或者我在哪里可以找到这个?
非常感谢!
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);
}
}