To do something at boot, you simply follow these steps.
First in manifest , this is added to the application tag:
<receiver android:name="AlarmReceiver"> <intent-filter> <action android:name="packagename.ACTION"/> <action android:name="packagename.ACTION2"/> </intent-filter> </receiver> <receiver android:name="BootSetter" > <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> </intent-filter> </receiver>
To do this, you need to add permission to receive broadcast in the manifest with the following line:
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
Then you have the BootSetter class:
public class BootSetter extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) {
There is a similar post, although not completely the same here . This means that an alarm goes off every day at noon.
source share