Fairly new to java/android but getting better slowly. I am trying to create a one time notification to remind the user about the app 24 hours after first run. I researched online and using stackoverflow, I was finally able to get the code to run with the following notification code:
private void addNotification() {
NotificationCompat.Builder builder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle("Notifications Example")
.setContentText("This is a test notification");
Intent notificationIntent = new Intent(this, MainActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent,
PendingIntent.FLAG_UPDATE_CURRENT);
builder.setContentIntent(contentIntent);
// Add as notification
NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
manager.notify(1, builder.build());
}
I am trying to call the notification function but it is not working. I am calling it as follows:
addNotification();
How do I proceed from here? I have not dealt with the 24 hr issue, just trying to get the notification to come up. Then upon clicking it, the app should start again.