I am putted my logic in android background service,which will be start on onClick action of my sticky notification.Everything working fine but problems are:-
- When I am lock my phone and try to click/tap on notification it requires double click/tap always.
- My logic is in background service but after clicked on notification Background service does not start until my mobile is unlocked.(Background service is sticky)
Below code is used for generate a sticky notification.
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);
}
Please suggest me the solution or need to set any flag in my code.