【发布时间】:2016-06-27 06:57:43
【问题描述】:
我将我的逻辑放在 android 后台服务中,这将在我的粘性通知的 onClick 操作上启动。一切正常,但问题是:-
- 当我锁定手机并尝试点击/点击通知时,它需要始终双击/点击。
- 我的逻辑是在后台服务中,但是点击通知后后台服务在我的手机解锁之前不会启动。(后台服务是粘性的)
以下代码用于生成粘性通知。
private void Notify() {
Context objContext = this.cordova.getActivity();
Intent objIntent = new Intent(objContext, ApiCallServeice.class);
PendingIntent pi = PendingIntent.getService(objContext, intNotificationId, objIntent, PendingIntent.FLAG_CANCEL_CURRENT);
Notification.Builder builder = new Notification.Builder(objContext);
builder.setContentTitle("Click to get help.");
builder.setAutoCancel(false);
builder.setSmallIcon(objContext.getApplicationInfo().icon);
builder.setOngoing(true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
builder.setVisibility(Notification.VISIBILITY_PUBLIC);
}
builder.setContentIntent(pi);
builder.build();
myNotication = builder.getNotification();
manager.notify(intNotificationId, myNotication);
}
请建议我解决方案或需要在我的代码中设置任何标志。
【问题讨论】:
标签: android notifications lockscreen lockscreenwidget