daily pastebin goal
30%
SHARE
TWEET

Untitled

a guest Mar 23rd, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. private void everydayAlarm(){
  2.         Intent intent = new Intent(MainActivity.this, AlarmReciver.class);
  3.        // PendingIntent pendingIntent = PendingIntent.getActivity(this,0,intent,0);
  4.         PendingIntent pendingIntent = PendingIntent.getBroadcast(this,0,intent,0);
  5.         AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
  6.  
  7.         Calendar calendar = Calendar.getInstance();
  8.         calendar.setTimeInMillis(System.currentTimeMillis());
  9.         calendar.set(Calendar.HOUR_OF_DAY, 16);
  10.         calendar.set(Calendar.MINUTE, 17); // minute start 0 index
  11.  
  12.         alarmManager.setInexactRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), AlarmManager.INTERVAL_DAY, pendingIntent);
  13.  
  14.         Log.d("mtest", "everydayAlarm starting.........: ");
  15.     }
  16.  
  17. public class AlarmReciver extends BroadcastReceiver {
  18.     @Override
  19.     public void onReceive(Context context, Intent intent) {
  20.         Log.d("mtest", "everydayAlarm working..........: ");
  21.     }
  22. }
  23.  
  24. //menifest
  25.  
  26. <receiver android:name=".reciver.AlarmReciver"
  27.             android:permission="android.permission.BIND_JOB_SERVICE"
  28.             android:exported="true"/>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top