AlarmManager用法

private void registerCoolReceiver() {

   BroadcastReceiver intentFilter = new GlobalReceiver();
   IntentFilter receiver = new IntentFilter(Intent.ACTION_SCREEN_OFF);
   registerReceiver(intentFilter, receiver);
   receiver = new IntentFilter("abc");
   registerReceiver(intentFilter, receiver);




   Intent intent = new Intent();
   intent.setAction("abc");
   PendingIntent pendingIntent = PendingIntent.
         getBroadcast(mContext, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);


   AlarmManager manager = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE);
   manager.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + 1000,
         1000, pendingIntent);


}

你可能感兴趣的:(AlarmManager用法)