【发布时间】:2017-07-05 08:03:51
【问题描述】:
当用户在我的应用中收到视频通话时,我会发出通知。
我的通知:
Intent intent1 = new Intent(Intent.ACTION_CAMERA_BUTTON);
Uri uri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);
PendingIntent pendingIntent = PendingIntent.getActivity(context,0,intent1,0);
NotificationCompat.Action action = new NotificationCompat.Action(R.drawable.ic_camera_notification,"Ok",pendingIntent);
NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
.setContentTitle("TITRE !!")
.setContentText("Test")
.setPriority(Notification.PRIORITY_HIGH)
.setCategory(Notification.CATEGORY_CALL)
.setSmallIcon(R.drawable.ic_camera_notification)
.addAction(action)
.setSound(uri)
.setAutoCancel(true)
.setVibrate(new long[] { 1000, 1000});
NotificationManager notificationManager = (NotificationManager) context.getSystemService(NOTIFICATION_SERVICE);
Notification notification = builder.build();
notificationManager.notify(11,notification);
要重复通知直到用户回答(或有限时间),我想添加一个计时器(如在此处解释:What is the equivalent to a JavaScript setInterval/setTimeout in Android/Java?)
但是当用户做出选择时,我想停止计时器。但是没有onClickListener,只有Intent。
我该怎么做?谢谢
【问题讨论】: