我正在使用Clean master app。我想自动安排干净的主缓存清理。如何在Android中使用某些应用或某些代码执行此操作?
感谢。
答案 0 :(得分:0)
您可以使用Alarm Manager安排您的应用程序在将来的某个时间运行 调度重复警报: 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);}