Guest User

Untitled

a guest
Sep 24th, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1. public static void AlarmOtherLocation(Context mContext, String type, LatLng latLng)
  2. {
  3.  
  4. AlarmManager alarmManager = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE);
  5. Random random = new Random();
  6. int expireCode = random.nextInt(9999 - 1000) + 1000;
  7.  
  8. Log.e("AlarmLocation","AlarmOtherLocation_code>>>"+expireCode);
  9.  
  10. ArrayList<LatLngType> arrayList_ = (ArrayList<LatLngType>) Utils.getLocation2(mContext);
  11.  
  12. arrayList_.get(0).setAlarmID(expireCode);
  13.  
  14. Utils.setLocation2(mContext,arrayList_);
  15.  
  16.  
  17. //30.705318852820483,76.7069748044014
  18.  
  19. double longitude = latLng.latitude;
  20. double latitude = latLng.longitude;
  21.  
  22. Intent notificationIntent = new Intent("android.media.action.DISPLAY_NOTIFICATION_AlarmReceiverLocation01001");
  23. notificationIntent.setClass(mContext, AlarmReceiverLocation.class);
  24. notificationIntent.addCategory("android.intent.category.DEFAULT");
  25. notificationIntent.putExtra("type", type);
  26. notificationIntent.putExtra("locationType", "other");
  27. notificationIntent.putExtra("savedLat", longitude);
  28. notificationIntent.putExtra("savedLng", latitude);
  29. notificationIntent.putExtra("expireCode", expireCode);
  30. //notificationIntent.putExtra("DATA",abc);
  31. PendingIntent broadcast = PendingIntent.getBroadcast(mContext, expireCode, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
  32. ////////////////////////////////////////////////////
  33.  
  34. Calendar calendar = Calendar.getInstance();
  35. Calendar now = Calendar.getInstance();
  36.  
  37. calendar.set(Calendar.HOUR_OF_DAY, 11);
  38. calendar.set(Calendar.MINUTE, 0);
  39. calendar.set(Calendar.SECOND, 0);
  40. calendar.set(Calendar.MILLISECOND, 0);
  41.  
  42. try
  43. {
  44. Log.e("AlarmLocation","AlarmOtherLocation_code222>>>");
  45. alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(),
  46. 300000L, broadcast);
  47. }
  48. catch (Exception e)
  49. {
  50. Log.e("AlarmLocation","AlarmWorkLocation_code_ex>>>"+e);
  51. }
  52.  
  53. }
Add Comment
Please, Sign In to add comment