Answer the question
In order to leave comments, you need to log in
Why doesn't the notification appear?
I'm trying to call a notification from the service, but for some reason it's not there.
//Notification
NotificationCompat.Builder builder =
new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.ic_notifications_black_24dp)
.setContentTitle("Status")
.setContentText("Voltage: "+currentVoltageStr)
.setPriority(-2);
int NOTIFICATION_ID = 12345;
Intent targetIntent = new Intent(context, HomeFragment.class);
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, targetIntent, PendingIntent.FLAG_UPDATE_CURRENT);
builder.setContentIntent(contentIntent);
NotificationManager nManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
assert nManager != null;
nManager.notify(NOTIFICATION_ID, builder.build());
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question