Guest User

Untitled

a guest
Jan 17th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. public void setRepeatingAlarm(){
  2. Intent intent = new Intent(this, TimeAlarm.class);
  3. PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0,intent, PendingIntent.FLAG_UPDATE_CURRENT);
  4. am.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), (5 * 1000), pendingIntent);
  5. }
  6.  
  7. public void onReceive(Context context, Intent intent) {
  8.  
  9. nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
  10. CharSequence from = "Homework";
  11. CharSequence message = "test"+ MainActivity.arraytest[x2]+ x2;
  12. x2 +=1;
  13. PendingIntent contentIntent = PendingIntent.getActivity(context, 0,new Intent(context,TimeAlarm.class), 0);
  14. Notification notif = new Notification(R.drawable.ic_launcher,"Update", System.currentTimeMillis());
  15. notif.setLatestEventInfo(context, from, message, contentIntent);
  16. nm.notify(notify_id, notif);
  17. }
Add Comment
Please, Sign In to add comment