List of usage examples for android.content Context ALARM_SERVICE
String ALARM_SERVICE
To view the source code for android.content Context ALARM_SERVICE.
Click Source Link
From source file:com.example.gemswin.screencastrecevertest.MainActivity_Reciever.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main_reciever); WifiManager wm = (WifiManager) getSystemService(WIFI_SERVICE); String ip = Formatter.formatIpAddress(wm.getConnectionInfo().getIpAddress()); TextView text = (TextView) findViewById(R.id.textView); planetList = new ArrayList<String>(); mTextureView = (TextureView)findViewById(R.id.textureView); mTextureView.setSurfaceTextureListener(this); mTextureView.requestLayout();/* ww w. j a v a 2 s . c om*/ mTextureView.invalidate(); mTextureView.setOpaque(false); logout = (Button) findViewById(R.id.logout); cast = (Button) findViewById(R.id.castAsmaster); doubtbutton = (Button) findViewById(R.id.doubt); viewbutton = (Button) findViewById(R.id.viewdoubt); pref = new PrefManager(getApplicationContext()); text.setText(ip); logout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { pref.logout(); Intent i = new Intent(MainActivity_Reciever.this, LoginActivity.class); startActivity(i); finish(); } }); cast.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { new allowcast().execute(); } }); viewbutton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //pref.logout(); // LOOK HERE ASH /*Intent i = new Intent(MainActivity_Reciever.this,DoubtActivity.class); startActivity(i);*/ new viewdoubttask().execute(); } }); doubtbutton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //pref.logout(); // LOOK HERE ASH /*Intent i = new Intent(MainActivity_Reciever.this,DoubtActivity.class); startActivity(i);*/ DoubtBox(); } }); mTask = new ReceiverAsyncTask(this); mTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); Intent intent1 = new Intent(this, MyBroadcastReceiver.class); intent1.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getBroadcast( getApplicationContext(), 234324243, intent1, PendingIntent.FLAG_UPDATE_CURRENT); AlarmManager alarmManager = (AlarmManager) getApplicationContext().getSystemService(Context.ALARM_SERVICE); alarmManager.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + (10 * 1000), pendingIntent); }
From source file:com.sean.takeastand.alarmprocess.ScheduledRepeatingAlarm.java
@Override public void unpause() { PendingIntent pendingIntent = createPausePendingIntent(mContext, mCurrentAlarmSchedule); AlarmManager am = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE); am.cancel(pendingIntent);// ww w . j a va 2s .c om setRepeatingAlarm(); Utils.setImageStatus(mContext, Constants.SCHEDULE_RUNNING); }
From source file:de.ub0r.android.portaltimer.UpdateReceiver.java
private void schedNext(final Context context) { Log.d(TAG, "schedNext()"); AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); Log.d(TAG, "current: " + mNow); long t;/* www . j ava 2s . co m*/ PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); if (pm.isScreenOn()) { t = mNow + 1000L; } else { t = mNextTarget - mNow; Log.d(TAG, "t: " + t); if (t < 0) { // IllegalState? t = 30000; } else if (t < 30000) { t = 5000; } else if (t < 60000) { t = 15000; } else { t = 30000; } Log.d(TAG, "t: " + t); long diff = mNextTarget - (mNow + t); diff = (diff / 5000) * 5000; Log.d(TAG, "diff: " + diff); if (diff == 0) { t = mNow + 5000; } else { t = mNextTarget - diff - 1000; } } Log.d(TAG, "next: " + t); long et; if (t - System.currentTimeMillis() < 100) { // IllegalState? et = 1000 + SystemClock.elapsedRealtime(); } else { et = t - System.currentTimeMillis() + SystemClock.elapsedRealtime(); } am.set(AlarmManager.ELAPSED_REALTIME, et, PendingIntent.getBroadcast(context, 0, new Intent(context, UpdateReceiver.class), PendingIntent.FLAG_UPDATE_CURRENT)); }
From source file:com.svpino.longhorn.activities.DashboardActivity.java
@Override protected void onPause() { ((AlarmManager) getSystemService(Context.ALARM_SERVICE)) .cancel(Extensions.createPendingIntent(this, Constants.SCHEDULE_AUTOMATIC)); if (this.searchDialog != null) { this.searchDialog.dismiss(); }/*from w ww . ja va 2s .co m*/ if (this.noConnectivityDialog != null) { this.noConnectivityDialog.dismiss(); } if (this.termsAndConditionsDialog != null) { this.termsAndConditionsDialog.dismiss(); } super.onPause(); }
From source file:com.jay.pea.mhealthapp2.utilityClasses.AlarmReceiver.java
public void SetAlarm(Context context) { AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); Intent intent = new Intent(context, AlarmReceiver.class); intent.putExtra(ONE_TIME, Boolean.FALSE); PendingIntent pi = PendingIntent.getBroadcast(context, 0, intent, 0); //After after 30 seconds am.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), 1000 * 5, pi); }
From source file:ca.etsmtl.applets.etsmobile.NewsListActivity.java
private void setAlarm() { final Intent toAlarm = new Intent(this, NewsAlarmReceiver.class); final PendingIntent toDownload = PendingIntent.getBroadcast(this, 0, toAlarm, PendingIntent.FLAG_CANCEL_CURRENT); final AlarmManager alarms = (AlarmManager) getSystemService(Context.ALARM_SERVICE); final Calendar updateTime = Calendar.getInstance(); updateTime.setTimeZone(TimeZone.getTimeZone("GMT")); updateTime.set(Calendar.HOUR_OF_DAY, 6); updateTime.set(Calendar.MINUTE, 00); alarms.setInexactRepeating(AlarmManager.RTC_WAKEUP, updateTime.getTimeInMillis(), AlarmManager.INTERVAL_DAY, toDownload);/* w w w . jav a 2 s.c o m*/ updateTime.set(Calendar.HOUR_OF_DAY, 12); alarms.setInexactRepeating(AlarmManager.RTC_WAKEUP, updateTime.getTimeInMillis(), AlarmManager.INTERVAL_DAY, toDownload); updateTime.set(Calendar.HOUR_OF_DAY, 18); alarms.setInexactRepeating(AlarmManager.RTC_WAKEUP, updateTime.getTimeInMillis(), AlarmManager.INTERVAL_DAY, toDownload); }
From source file:com.google.android.apps.santatracker.notification.SantaNotificationBuilder.java
/** * Schedule a basic notification at an approximate time. *///ww w. j a va2 s . c om public static void ScheduleSantaNotification(Context c, long timestamp, int notificationType) { // Only schedule a notification if the time is in the future if (timestamp < System.currentTimeMillis()) { return; } AlarmManager alarm = (AlarmManager) c.getSystemService(Context.ALARM_SERVICE); Intent i = new Intent(c, NotificationBroadcastReceiver.class); i.putExtra(NotificationConstants.KEY_NOTIFICATION_ID, NotificationConstants.NOTIFICATION_ID); // Type is "takeoff", "location", etc. i.putExtra(NotificationConstants.KEY_NOTIFICATION_TYPE, notificationType); // Generate unique pending intent PendingIntent pi = PendingIntent.getBroadcast(c, notificationType, i, 0); // Deliver next time the device is woken up alarm.set(AlarmManager.RTC, timestamp, pi); }
From source file:com.gmail.at.faint545.fragments.QueueFragment.java
private void setRecurringAlarm() { if (getRemote().getRefreshInterval() != -1) { updateTime = Calendar.getInstance(); updateTime.setTimeZone(TimeZone.getTimeZone("GMT")); updateTime.set(Calendar.MINUTE, 1); Intent downloader = new Intent(getActivity(), AlarmReciever.class); downloader.putExtra("url", getRemote().buildURL()); downloader.putExtra("api", getRemote().getApiKey()); downloader.putExtra("messenger", new Messenger(handler)); PendingIntent recurringDownload = PendingIntent.getBroadcast(getActivity(), 0, downloader, PendingIntent.FLAG_CANCEL_CURRENT); AlarmManager alarms = (AlarmManager) getActivity().getSystemService(Context.ALARM_SERVICE); alarms.setInexactRepeating(AlarmManager.RTC_WAKEUP, updateTime.getTimeInMillis(), getRemote().getRefreshInterval(), recurringDownload); } else {// www.jav a2 s . c o m downloadQueue(null); } }
From source file:com.shinymetal.gradereport.AbstractActivity.java
protected void setRecurringAlarm(Context context, boolean force) { boolean alarmUp = (PendingIntent.getBroadcast(context, 0, new Intent(context, AlarmReceiver.class), PendingIntent.FLAG_NO_CREATE) != null); if (alarmUp && !force) return;//from w w w . j a v a 2 s.c o m Intent downloader = new Intent(context, AlarmReceiver.class); downloader.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, downloader, PendingIntent.FLAG_UPDATE_CURRENT); AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE); Date firstRun = new Date(); long mSyncInterval = Long.parseLong(PreferenceManager.getDefaultSharedPreferences(this) .getString(getString(R.string.pref_sync_key), "15")) * 60000; alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, firstRun.getTime() + 10, mSyncInterval, pendingIntent); if (BuildConfig.DEBUG) Log.d(this.toString(), TS.get() + this.toString() + " Set alarmManager.setRepeating to: " + firstRun.toString() + " interval: " + mSyncInterval); }
From source file:com.prod.intelligent7.engineautostart.ConnectDaemonService.java
@Override public void onCreate() { ramFileName = MainActivity.package_name + ".profile"; log = Logger.getAnonymousLogger(); log.info(getPackageName() + "Got Activated "); serverHeartBit = 60 * 1000;// w w w . j av a2s . c o m urgentMailBox = new ArrayList<String>(); if (mDaemon == null || !mDaemon.isAlive()) startDaemon(); scheduleAlarm = null; alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE); //startScheduledJobs(); //new screen off handling /* bugPresent = true; screenIsOff = false; final IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON); filter.addAction(Intent.ACTION_SCREEN_OFF); screenOnOffReceiver = new ScreenReceiver(); registerReceiver(screenOnOffReceiver, filter); powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE); WakeLockManager.acquire(this, "screenBugPartial", PowerManager.PARTIAL_WAKE_LOCK); registerAccelerometerListener(); */ startScheduleAlarms(); }