I've managed to have my notifications pop up at the press of a button, but I now want to further develop it so that the notification doesn't pop until X minutes (or Y hours) have passed since the button was pressed.
The relevant code:
private void sendNotif() {
notification.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.avatar));
notification.setTicker("Kayla has returned");
notification.setWhen(System.currentTimeMillis());
notification.setContentTitle("Kayla has returned");
notification.setContentText("See what news she has to share");
Intent notifIntent = new Intent(this, MainActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notifIntent, PendingIntent.FLAG_CANCEL_CURRENT);
notification.setContentIntent(pendingIntent);
NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
nm.notify(notifId, notification.build());
}
private void setNotif() {
Button btn = (Button) findViewById(R.id.notifBtn);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
sendNotif();
}
});
}
I've figured I need to use AlarmManager in some way, but I can't seem to incorporate it into the notification...