List of usage examples for android.app AlarmManager RTC_WAKEUP
int RTC_WAKEUP
To view the source code for android.app AlarmManager RTC_WAKEUP.
Click Source Link
From source file:com.lewa.crazychapter11.MainActivity.java
public boolean isLewaRom(Context context, Intent alarmIntent) { PackageManager pm = context.getPackageManager(); boolean isLewaRom = true; String version = ""; int versionCode = 0; PackageInfo pi = null;//from w w w . ja va 2s .c o m String testsr = null; try { // com.lewa.permmanager // pm.getPackageInfo("com.lewa.deviceactivate",PackageManager.GET_ACTIVITIES); pm.getPackageInfo("com.lewa.permmanager", PackageManager.GET_ACTIVITIES); pi = pm.getPackageInfo(context.getPackageName(), 0); version = pi.versionName; versionCode = pi.versionCode; } catch (PackageManager.NameNotFoundException e) { isLewaRom = false; } Log.d("algerheMain00", "isLewaRom : " + isLewaRom); Log.i("algerheVersion", "versionname=" + version + " \n getPackageName()=" + getPackageName() + " \n versioncode=" + versionCode); Log.i("algerheStr", "TextUtils.isEmpty(testsr) = " + TextUtils.isEmpty(testsr)); // Log.i("algerheStr","testsr.length="+testsr.length()); ///alarm test Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(System.currentTimeMillis()); calendar.set(Calendar.HOUR_OF_DAY, 16); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); alarmIntent.setAction("com.lewa.alarm.test"); PendingIntent pipi = PendingIntent.getBroadcast(context, 3359, alarmIntent, PendingIntent.FLAG_UPDATE_CURRENT); AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); Log.i("algerheAlarm", "send alarm message in time=" + System.currentTimeMillis()); // alarmManager.setExact(AlarmManager.RTC_WAKEUP, System.currentTimeMillis()+5000, pipi); alarmManager.setExact(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), pipi); // final Timer timer = new Timer(); // timer.schedule(new TimerTask() { // @Override // public void run() { // Message msg = new Message(); // msg.what = 0x2789; // handler.sendMessage(msg); // timer.cancel(); // } // }, 0, 5000); return isLewaRom; }
From source file:com.magnet.mmx.client.MMXClient.java
private static void scheduleWakeupAlarm(Context context, long interval) { if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "scheduleWakeupAlarm(): called with interval=" + interval); }/*w ww . j a v a2 s . c o m*/ AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); if (interval > 0) { //a time was set alarmManager.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + interval, getWakeupIntent(context)); } else { //cancel if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "scheduleWakeupAlarm(): cancelling alarm"); } alarmManager.cancel(getWakeupIntent(context)); } }
From source file:org.tigase.messenger.phone.pro.service.XMPPService.java
private void startKeepAlive() { Intent i = new Intent(); i.setClass(this, XMPPService.class); i.setAction(KEEPALIVE_ACTION);//from w ww . java 2 s . co m PendingIntent pi = PendingIntent.getService(this, 0, i, 0); AlarmManager alarmMgr = (AlarmManager) getSystemService(ALARM_SERVICE); alarmMgr.setInexactRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + keepaliveInterval, keepaliveInterval, pi); }
From source file:com.android.exchange.ExchangeService.java
private void setAlarm(long id, long millis) { synchronized (mPendingIntents) { PendingIntent pi = mPendingIntents.get(id); if (pi == null) { Intent i = new Intent(this, MailboxAlarmReceiver.class); i.putExtra("mailbox", id); i.setData(Uri.parse("Box" + id)); pi = PendingIntent.getBroadcast(this, 0, i, 0); mPendingIntents.put(id, pi); AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE); alarmManager.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + millis, pi); //log("+Alarm set for " + alarmOwner(id) + ", " + millis/1000 + "s"); }/*from w ww . j a va 2s .c o m*/ } }
From source file:com.zld.ui.ZldNewActivity.java
/** * ?Service???/*from ww w. j a v a2 s . co m*/ * * @param intent 1 * @param bundle 2 * @param action 3 */ private void serIntent(Intent intent, Bundle bundle, String action) { intent.setClass(ZldNewActivity.this, HomeExitPageService.class); bundle.putString(INTENT_KEY, action); intent.putExtras(bundle); PendingIntent sender = PendingIntent.getService(ZldNewActivity.this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE); am.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), sender); }
From source file:com.bangalore.barcamp.BCBUtils.java
public static void setAlarmForSession(Context context, Slot slot, Session session, int slotpos, int sessionpos) { BCBSharedPrefUtils.setAlarmSettingsForID(context, session.id, BCBSharedPrefUtils.ALARM_SET); PendingIntent intent = BCBUtils.createPendingIntentForID(context, session.id, slotpos, sessionpos); AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); int hour = slot.startTime / 100; int mins = slot.startTime % 100; Log.e("Session", "hour : " + hour + " mins :" + mins); GregorianCalendar date = new GregorianCalendar(2013, Calendar.SEPTEMBER, 14, hour, mins); long timeInMills = date.getTimeInMillis() - 300000; alarmManager.set(AlarmManager.RTC_WAKEUP, timeInMills, intent); }
From source file:de.rosche.spectraTelemetry.SpectraTelemetry.java
private void doService() { NotificationCompat.Builder builder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.aurorasmall).setContentTitle("Hitec Telemetry Service") .setContentText("started..."); int NOTIFICATION_ID = 12346; Intent targetIntent = new Intent(this, SpectraTelemetry.class); targetIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, targetIntent, 0); builder.setContentIntent(contentIntent); NotificationManager nManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); nManager.notify(NOTIFICATION_ID, builder.build()); Intent intent = new Intent(this, SpeakService.class); pendingIntent = PendingIntent.getService(this, 0, intent, 0); Calendar cal = Calendar.getInstance(); AlarmManager alarm = (AlarmManager) getSystemService(Context.ALARM_SERVICE); alarm.setRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), 10 * 1000, pendingIntent); }
From source file:com.codename1.impl.android.AndroidImplementation.java
public void scheduleLocalNotification(LocalNotification notif, long firstTime, int repeat) { final Intent notificationIntent = new Intent(getContext(), LocalNotificationPublisher.class); notificationIntent.setAction(getContext().getApplicationInfo().packageName + "." + notif.getId()); notificationIntent.putExtra(LocalNotificationPublisher.NOTIFICATION, createBundleFromNotification(notif)); Intent contentIntent = new Intent(); if (getActivity() != null) { contentIntent.setComponent(getActivity().getComponentName()); }// w w w . ja va2 s . c o m contentIntent.putExtra("LocalNotificationID", notif.getId()); if (BACKGROUND_FETCH_NOTIFICATION_ID.equals(notif.getId()) && getBackgroundFetchListener() != null) { Context context = AndroidNativeUtil.getContext(); Intent intent = new Intent(context, BackgroundFetchHandler.class); //there is an bug that causes this to not to workhttps://code.google.com/p/android/issues/detail?id=81812 //intent.putExtra("backgroundClass", getBackgroundLocationListener().getName()); //an ugly workaround to the putExtra bug intent.setData( Uri.parse("http://codenameone.com/a?" + getBackgroundFetchListener().getClass().getName())); PendingIntent pendingIntent = PendingIntent.getService(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); notificationIntent.putExtra(LocalNotificationPublisher.BACKGROUND_FETCH_INTENT, pendingIntent); } else { contentIntent.setData( Uri.parse("http://codenameone.com/a?LocalNotificationID=" + Uri.encode(notif.getId()))); } PendingIntent pendingContentIntent = PendingIntent.getActivity(getContext(), 0, contentIntent, PendingIntent.FLAG_UPDATE_CURRENT); notificationIntent.putExtra(LocalNotificationPublisher.NOTIFICATION_INTENT, pendingContentIntent); PendingIntent pendingIntent = PendingIntent.getBroadcast(getContext(), 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); AlarmManager alarmManager = (AlarmManager) getContext().getSystemService(Context.ALARM_SERVICE); if (BACKGROUND_FETCH_NOTIFICATION_ID.equals(notif.getId())) { alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, firstTime, getPreferredBackgroundFetchInterval() * 1000, pendingIntent); } else { if (repeat == LocalNotification.REPEAT_NONE) { alarmManager.set(AlarmManager.RTC_WAKEUP, firstTime, pendingIntent); } else if (repeat == LocalNotification.REPEAT_MINUTE) { alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, firstTime, 60 * 1000, pendingIntent); } else if (repeat == LocalNotification.REPEAT_HOUR) { alarmManager.setInexactRepeating(AlarmManager.RTC_WAKEUP, firstTime, AlarmManager.INTERVAL_HALF_HOUR, pendingIntent); } else if (repeat == LocalNotification.REPEAT_DAY) { alarmManager.setInexactRepeating(AlarmManager.RTC_WAKEUP, firstTime, AlarmManager.INTERVAL_DAY, pendingIntent); } else if (repeat == LocalNotification.REPEAT_WEEK) { alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, firstTime, AlarmManager.INTERVAL_DAY * 7, pendingIntent); } } }