List of usage examples for android.app PendingIntent FLAG_NO_CREATE
int FLAG_NO_CREATE
To view the source code for android.app PendingIntent FLAG_NO_CREATE.
Click Source Link
From source file:com.twentyoneechoes.borges.util.Utils.java
private static boolean isAlarmAlreadySet(Context context) { Intent intent = new Intent(context, LibraryUpdateService.class); PendingIntent pi = PendingIntent.getService(context, LIBRARY_UPDATE_REQUEST_CODE, intent, PendingIntent.FLAG_NO_CREATE); return pi != null; }
From source file:org.chromium.ChromeNotifications.java
private static void triggerJavascriptEventNow(Context context, ComponentName componentName, EventInfo eventInfo) {//from w w w.j av a 2 s .com Intent intent = new Intent(); intent.setComponent(componentName); intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); if (NOTIFICATION_CLICKED_ACTION.equals(eventInfo.action)) { webView.sendJavascript("chrome.notifications.triggerOnClicked('" + eventInfo.notificationId + "')"); context.startActivity(intent); } else if (NOTIFICATION_CLOSED_ACTION.equals(eventInfo.action)) { PendingIntent pendingIntent = makePendingIntent(context, componentName, NOTIFICATION_CLICKED_ACTION, eventInfo.notificationId, -1, PendingIntent.FLAG_NO_CREATE); if (pendingIntent != null) { pendingIntent.cancel(); } webView.sendJavascript("chrome.notifications.triggerOnClosed('" + eventInfo.notificationId + "')"); } else if (NOTIFICATION_BUTTON_CLICKED_ACTION.equals(eventInfo.action)) { webView.sendJavascript("chrome.notifications.triggerOnButtonClicked('" + eventInfo.notificationId + "', " + eventInfo.buttonIndex + ")"); context.startActivity(intent); } }
From source file:com.concentricsky.android.khanacademy.app.HomeActivity.java
private void setupRepeatingLibraryUpdateAlarm() { Log.d(LOG_TAG, "setupRepeatingLibraryUpdateAlarm"); AlarmManager am = (AlarmManager) getSystemService(Activity.ALARM_SERVICE); Intent intent = new Intent(getApplicationContext(), KADataService.class); intent.setAction(ACTION_LIBRARY_UPDATE); PendingIntent existing = PendingIntent.getService(getApplicationContext(), REQUEST_CODE_RECURRING_LIBRARY_UPDATE, intent, PendingIntent.FLAG_NO_CREATE); boolean alreadyScheduled = existing != null; if (!alreadyScheduled) { // Initial delay. Calendar cal = Calendar.getInstance(); cal.add(Calendar.SECOND, UPDATE_DELAY_FROM_FIRST_RUN); // Schedule the alarm. PendingIntent pendingIntent = PendingIntent.getService(getApplicationContext(), REQUEST_CODE_RECURRING_LIBRARY_UPDATE, intent, PendingIntent.FLAG_CANCEL_CURRENT); Log.d(LOG_TAG, "(re)setting alarm"); am.setRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), AlarmManager.INTERVAL_DAY, pendingIntent);// w ww .j a va2s . c om } }
From source file:com.jerrellmardis.amphitheatre.util.Utils.java
private static boolean isAlarmAlreadySet(Context context, Class c) { Intent intent = new Intent(context, c); PendingIntent pi = PendingIntent.getService(context, LIBRARY_UPDATE_REQUEST_CODE, intent, PendingIntent.FLAG_NO_CREATE); return pi != null; }
From source file:com.adguard.android.service.FilterServiceImpl.java
@Override public void scheduleFiltersUpdate() { Intent alarmIntent = new Intent(AlarmReceiver.UPDATE_FILTER_ACTION); boolean isRunning = PendingIntent.getBroadcast(context, 0, alarmIntent, PendingIntent.FLAG_NO_CREATE) != null; if (!isRunning) { LOG.info("Starting scheduler of filters updating"); PendingIntent broadcastIntent = PendingIntent.getBroadcast(context, 0, alarmIntent, 0); AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, UPDATE_INITIAL_PERIOD, AlarmManager.INTERVAL_HOUR, broadcastIntent);//from w ww. j a va 2 s. co m } else { LOG.info("Filters update is running"); } }
From source file:com.remdo.app.MainActivity.java
/** * This method checks services state, and configure MainActivity layout to be displayed accordingly. *///from w w w. ja va 2 s .co m private void checkServices() { TextView TVGeo = (TextView) findViewById(R.id.tv_geo_footer); TextView TVAlerts = (TextView) findViewById(R.id.tv_alerts_footer); Intent myIntent = new Intent(this, GeopositioningService.class); pendingGeoIntent = PendingIntent.getService(this, 0, myIntent, PendingIntent.FLAG_NO_CREATE); myIntent = new Intent(this, NotificationService.class); pendingAlertsIntent = PendingIntent.getService(this, 0, myIntent, PendingIntent.FLAG_NO_CREATE); //Comprobamos si el servicio GEO esta iniciado if (!isGEORunning()) { TVGeo.setTextColor(this.getResources().getColor(R.color.Red)); TVGeo.setText(R.string.geo_off); GeoEnabled = false; } else { TVGeo.setTextColor(this.getResources().getColor(R.color.Black)); TVGeo.setText(R.string.geo_on); GeoEnabled = true; } //Comprobamos si el servicio Alerts esta iniciado if (!isALERTSRunning()) { TVAlerts.setTextColor(this.getResources().getColor(R.color.Red)); TVAlerts.setText(R.string.alerts_off); AlertsEnabled = false; } else { TVAlerts.setTextColor(this.getResources().getColor(R.color.Black)); TVAlerts.setText(R.string.alerts_on); AlertsEnabled = true; } }
From source file:net.peterkuterna.android.apps.devoxxfrsched.service.CfpSyncManager.java
/** * Retreive the currently installed {@link PendingIntent} for the alarm. * //from ww w . j a va2s .com * @return */ private PendingIntent getAlarmPendingIntent() { final Context context = getContext(); final Intent intent = new Intent(context, OnAlarmReceiver.class); return PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_NO_CREATE); }
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 ww . j av a 2s . co 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:at.ac.uniklu.mobile.sportal.service.MutingService.java
/** * Determines if the muting service is running (ON) or stopped (OFF). * The muting service is defined as running if there is an alarm scheduled that will either mute or unmute * the phone at a specific time. It is stopped if no alarm is scheduled. * http://code.google.com/p/android/issues/detail?id=3776 * http://stackoverflow.com/questions/2110620/how-to-handle-an-alarm-triggered-each-day-in-android * @return true if the muting service is running or false if it is stopped */// w w w .ja v a 2 s. com private boolean isRunning() { Intent alarmIntent = new Intent(this, OnAlarmReceiver.class).putExtra(ACTION, ACTION_NONE); boolean isRunning = PendingIntent.getBroadcast(this, 0, alarmIntent, PendingIntent.FLAG_NO_CREATE) != null; Log.d(TAG, "isRunning(): " + isRunning); return isRunning; }
From source file:edu.mit.media.funf.probe.Probe.java
private void loadRequestsIntent(Intent currentIntent) { if (isRequestsIntent(currentIntent)) { Log.d(TAG, "Is requests intent."); requestsIntent = currentIntent;/* ww w . jav a2 s .co m*/ } else { // Attempt to grab pending intent and send Otherwise initialize requestsIntent Intent internalRunIntent = getRequestsIntent(); PendingIntent selfLaunchingIntent = PendingIntent.getService(this, 0, internalRunIntent, PendingIntent.FLAG_NO_CREATE); if (selfLaunchingIntent == null) { requestsIntent = internalRunIntent; } else { try { Log.i(TAG, "Sending requests pending intent and waiting"); selfLaunchingIntent.send(); queueIntent(currentIntent, true); pauseQueueUntilIntentReceived(internalRunIntent, null); } catch (CanceledException e) { Log.e(TAG, "CANCELLED INTERNAL RUN INTENT"); requestsIntent = internalRunIntent; } } } }