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