Good day, who knows how to create a notification (not Push Notification, but something like a notification in the Organizer or Notes), which at a specified time will pop up and remind the user of something.
2 answers
You may be interested to create reminders in the Google Calendar (Since you do not want Push - notifications). https://github.com/vovaksenov99/Google_calendar_work Here for example here I combined work with Google a calendar in a class. Not everything has been completed there, but if necessary, I will complete the documentation.
|
You can use standard Android notifications https://developer.android.com/guide/topics/ui/notifiers/notifications.html
Creating a simple notification:
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.notification_icon) .setContentTitle("My notification") .setContentText("Hello World!"); // Creates an explicit intent for an Activity in your app Intent resultIntent = new Intent(this, ResultActivity.class); // The stack builder object will contain an artificial back stack for the // started Activity. // This ensures that navigating backward from the Activity leads out of // your application to the Home screen. TaskStackBuilder stackBuilder = TaskStackBuilder.create(this); // Adds the back stack for the Intent (but not the Intent itself) stackBuilder.addParentStack(ResultActivity.class); // Adds the Intent that starts the Activity to the top of the stack stackBuilder.addNextIntent(resultIntent); PendingIntent resultPendingIntent = stackBuilder.getPendingIntent( 0, PendingIntent.FLAG_UPDATE_CURRENT ); mBuilder.setContentIntent(resultPendingIntent); NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); // mId allows you to update the notification later on. mNotificationManager.notify(mId, mBuilder.build()); Is done. Now the user will receive a notification.
- Although the link can find the answer to the question, it is better to point out the most important thing here, and give the link as a source. If the page to which the link leads will be changed, the response link may become invalid. - From the queue of checks - Nikotin N
- Yes. Added code to create a simple notification. - Andrew Grow
|