Advertisement
Ranex

Untitled

Sep 27th, 2020
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.60 KB | None | 0 0
  1. private void setAlarm(long timeInMillis) {
  2.         AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
  3.         Intent intent = new Intent(this, MyAlarm.class);
  4.         PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0,intent,0);
  5.         alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, timeInMillis, AlarmManager.INTERVAL_DAY,pendingIntent);
  6.     }
  7. ...
  8. public class MyAlarm extends BroadcastReceiver{
  9.     @Override
  10.     public void onReceive(Context context, Intent intent) {
  11.         Toast.makeText(context, "Бах!", Toast.LENGTH_SHORT).show();
  12.     }
  13.  
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement