Reputation: 6986
I am planning to create an Android app that will have some time-consuming tasks (for example; filling out a large form). I don't want to bother an user when they are busy doing things or when they have an appointment. Is there any way to determine when a user is not busy, and to snooze a notification to a -for the user- convenient time?
Upvotes: 1
Views: 66
Reputation: 224
You can combine d.santos's suggestion with listening for accelerometer's readings .
For example , you ask the user to fill out the form when he doesn't have any events in the calendar and the accelerometer readings are showing a lack of activity
Here You can find how to use SensorEventListener
to monitor accelerometer's reading changes
Upvotes: 0
Reputation: 115
One way might be to request access to the user's calendar, see here an example of how you could do so: https://developer.android.com/training/permissions/requesting.html
In your situation you would request permissions to READ_CALENDAR, this could be in an xml configuration file or within your code as detailed above. You could then consume this information and opt to not send out the notification if the user has a scheduled appointment at the time of the check.
Snippet below would check if you have permissions to read the users calendar:
// Assume thisActivity is the current activity
int permissionCheck = ContextCompat.checkSelfPermission(thisActivity,
Manifest.permission.READ_CALENDAR);
Upvotes: 1