I'm trying to have Notification very time the Job service run. It's not working. I want to know the right way of providing notification when the Job service is enabled. Please help me in understanding these concepts and how to make it work? Note: Scheduling is working, I'm trying to add Notification, which is not working.
public class GuardianJobService extends JobService{
public final int REQUEST_CODE_ASK_PERMISSIONS = 1001;
@Override
public boolean onStartJob(JobParameters params) {
enableTracking();
addNotification();
return true;
}
@Override
public boolean onStopJob(JobParameters params) {
return true;
}
private void addNotification() {
NotificationCompat.Builder builder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.alert_icon)
.setContentTitle("Notifications Example")
.setContentText("This is a test notification");
Intent notificationIntent = new Intent(this, LoginActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent,
PendingIntent.FLAG_UPDATE_CURRENT);
builder.setContentIntent(contentIntent);
NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
manager.notify(0, builder.build());
}
public void enableTracking() {
......
}
}
I think there are some potential problems