Reputation: 1245
I checked almost all questions in stack overflow and also in google documentation and still couldn't understand what to use exactly for my cases.
What i want is, user will select reminder date in the app and in that time app will send a notification even app is closed or phone restarted between remind set time and remind time.
So what do i need to use? Which classes do i need? Broadcast Receiver, AlarmManager these two is enough or what? a sample of code 20-30 lines would be nice =)
Upvotes: 1
Views: 2218
Reputation: 23
For re-setting Alarm Notification, use
<receiver android:name=".AfterBootReceiver" android:label="AfterBootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"></action>
</intent-filter>
and
@Override public void onReceive(Context context,Intent intent){
...
}
to reset AlarmManager.set after device re-booted.
Upvotes: 0
Reputation: 1466
Check Android Developers website for calender intents so you can use them to determine the time etc. On your broadcast receiver pass the details or timing to the broadcast receiver. Once you do that use the alarm manager etc to check if the time is perfect and simply send a push notification when the time is correct.
I say this assuming that you know already about the calendar, alarm manager, and broadcast receivers intents. If you don't I recommend googling the following with Android Developers appended to it.
Upvotes: 1
Reputation: 1359
You will need both a few things.
Setup: You need to set your app to listen for the phone starting by registering for this intent in your manifest.
Basically you when your user selects the time, you will need to:
If your app ever gets the broadcast that the phone was rebooted, then all of your alarms are lost. You need to reset them using the times you saved in the file/db/shared prefs.
Upvotes: 1