I am building a note app, that uses alarm manager to set multiple notifications, but when a reboot the phone, the notification is not showing up.
I tried to save notifications in a db, but is not working.
Can anyone help me?
I am building a note app, that uses alarm manager to set multiple notifications, but when a reboot the phone, the notification is not showing up.
I tried to save notifications in a db, but is not working.
Can anyone help me?
Here is how you start your app after reboot automatically. After restart, check your db and re-post the notifications, what you need.
You need to add a receiver that launches a Service after a reboot.
In your manifest register for Boot Complete
... ...
In your boot receiver, launch a service.
public class MyRebootReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Intent serviceIntent = new Intent(context, MeCorpServiceClass.class);
serviceIntent.putExtra("caller", "RebootReceiver");
context.startService(serviceIntent);
}
}
Here is an example for a service class to run in the background.
public class MeCorpServiceClass extends IntentService{
@Override
protected void onHandleIntent(Intent intent){
String intentType = intent.getExtras().getString("caller");
if(intentType == null) return;
if(intentType.Equals("RebootReceiver"))
//Do reboot stuff
//handle other types of callers, like a notification.
}
}
OR Just use a third party like Urban AirShip, which handles all that for you.