AlarmManager delete all schedules on power-off?

前端 未结 3 483
無奈伤痛
無奈伤痛 2021-01-06 14:16

I have set an alarm at specific time. If the phone is turn off the alarm is lost? I have turn off the phone, start it again but the alarm did not trigger at the specified ti

3条回答
  •  再見小時候
    2021-01-06 14:32

    Tried @Woodsy Method but didn't work so i fixed some things so it can work

    public class BootReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        if ("android.intent.action.BOOT_COMPLETED".equals(intent.getAction())) {
    
            Log.d("receiver", "The Receiver is called");
            Intent mServiceIntent = new Intent(context, BootService.class);
            context.startService(mServiceIntent);
    
        } else {
            Log.d("boot receiver ",
                    "Something went wrong with the boot complete maybe with permissions ");
        }
    }
    

    }

    *Permissions & Manifest *

    
    
    
    
    Booting update 
            
    
            
                
                    
                    
                
           
    

    Hope this could help others

提交回复
热议问题