简体   繁体   中英

Auto schedule tasks Android

I am using Clean master app. I want to auto schedule the clean master cache cleaning. How can I do that in Android using some app or some code?

Thanks.

you can use Alarm Manager schedule your application to be run at some point in the future Scheduling Repeating Alarms : https://developer.android.com/training/scheduling/alarms.html

public void cleanup(DateTime dateTime){
 Intent alarmIntent = new Intent(Forms.Context, typeof(AlarmReceiver));
  PendingIntent pendingIntent = PendingIntent.GetBroadcast(Forms.Context, 0, alarmIntent, PendingIntentFlags.UpdateCurrent);
AlarmManager alarmManager = (AlarmManager) Forms.Context.GetSystemService(Context.AlarmService);

//TODO: For demo set after 5 seconds.
alarmManager.Set(AlarmType.ElapsedRealtime, SystemClock.ElapsedRealtime () + 5 * 1000, pendingIntent);}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM