peace
peace

Reputation: 71

What is best way to show notification at a certain time in Android?

I am working on an ToDo app. One user can choose a reminder date for any task and my app will able to show notification at the date which the user selected for reminder. I did research about on this subject. I found that I can use AlarmManager, PendingIntent, WorkManager etc...But I don't know that which way is best. Can you give me an idea which method i should use?

Upvotes: 0

Views: 65

Answers (1)

Nikos Hidalgo
Nikos Hidalgo

Reputation: 3756

In order to choose the right solution for your project you need to think about the following three questions:

Can the work be deferred, or does it need to happen right away? For example, if you need to fetch some data from the network in response to the user clicking a button, that work must be done right away. However, if you want to upload your logs to the server, that work can be deferred without affecting your app’s performance or user expectations.

Is the work dependent on system conditions? You might want your job to run only when the device meets certain conditions, such as being connected to power, having internet connectivity, and so on. For example, your app might periodically need to compress its stored data. To avoid affecting the user, you would want this job to happen only when the device is charging and idle.

Does the job need to run at a precise time? A calendar app might let a user set up a reminder for an event at a specific time. The user expects to see the reminder notification at the correct time. In other cases, the app may not care precisely when the job runs. The app might have general requirements—like, "Job A must run first, then Job B, then Job C"—but it doesn't require jobs to run at a specific time.

(source)

enter image description here

Upvotes: 1

Related Questions