List of usage examples for android.content Intent ACTION_BOOT_COMPLETED
String ACTION_BOOT_COMPLETED
To view the source code for android.content Intent ACTION_BOOT_COMPLETED.
Click Source Link
From source file:com.hplasplas.reminders.services.NotificationService.java
private Intent createNextIntent(Intent handledIntent) { if (handledIntent.getAction() != null && handledIntent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) { return new Intent(this.getApplicationContext(), NotificationService.class); } else {// ww w . j a v a2 s . co m return handledIntent; } }
From source file:com.hplasplas.reminders.services.NotificationService.java
private boolean isPostBoot(Intent handledIntent) { return handledIntent.getAction() != null && handledIntent.getAction().equals(Intent.ACTION_BOOT_COMPLETED); }
From source file:me.piebridge.prevent.framework.SystemReceiver.java
private void handleNonScheme(String action) { if (Intent.ACTION_SCREEN_OFF.equals(action)) { onScreenOff();// ww w . ja v a 2 s. c o m } else if (Intent.ACTION_SCREEN_ON.equals(action)) { onScreenOn(); } else if (Intent.ACTION_BOOT_COMPLETED.equals(action)) { if (!SystemHook.isSupported()) { PreventListUtils.notifyNotSupported(mContext); } else if (!PreventListUtils.getInstance().canLoad(mContext)) { PreventListUtils.notifyNoPrevents(mContext); } } }
From source file:org.universAAL.android.services.MiddlewareService.java
@Override public int onStartCommand(final Intent intent, int flags, int startId) { // This will be called each time someone (scan/boot/wifi) sends an intent to this service. Analyze and react accordingly. Log.v(TAG, "Start command: "); // HACK: Set user type for AndroidHandler. Prevents NPE at startup when activity is not visible mUserType = Integer.parseInt(PreferenceManager.getDefaultSharedPreferences(MiddlewareService.this) .getString("setting_type_key", Integer.toString(AppConstants.Defaults.TYPE))); new Thread(new Runnable() { public void run() { if (intent != null) { String action = intent.getAction(); Log.v(TAG, "Intent action: " + action); if (action != null) { if (action.equals(Intent.ACTION_BOOT_COMPLETED)) { //Do nothing, the MW is already started by now in oncreate Log.v(TAG, "Action is BOOT"); } else if (action.equals(ConnectivityManager.CONNECTIVITY_ACTION) || action.equals("android.net.wifi.STATE_CHANGE")) { // Only react to meaningful changes Log.v(TAG, "Action is WIFI"); int newWifi = checkWifi(); //Dont set mCurrentWifi yet, we have to compare if (Config.isWifiAllowed()) { boolean modeGW = (Config.getRemoteMode() == AppConstants.REMOTE_MODE_WIFIOFF); switch (newWifi) { case AppConstants.WIFI_OFF: if (mCurrentWIFI == AppConstants.WIFI_NOTSET || mCurrentWIFI == AppConstants.WIFI_HOME) { if (modeGW) { stopGateway(); }/*from w w w. j a va 2s. co m*/ restartConnector(false); // Shut down jSLP, use GW if (modeGW) { startGateway(); } } break; case AppConstants.WIFI_NOTSET: if (mCurrentWIFI == AppConstants.WIFI_OFF || mCurrentWIFI == AppConstants.WIFI_STRANGER) { if (modeGW) { stopGateway(); } restartConnector(true); // Turn on jSLP, dont use GW } break; case AppConstants.WIFI_STRANGER: if (mCurrentWIFI == AppConstants.WIFI_NOTSET || mCurrentWIFI == AppConstants.WIFI_HOME) { if (modeGW) { stopGateway(); } restartConnector(false); // Shut down jSLP, use GW if (modeGW) { startGateway(); } } break; case AppConstants.WIFI_HOME: if (mCurrentWIFI == AppConstants.WIFI_OFF || mCurrentWIFI == AppConstants.WIFI_STRANGER) { if (modeGW) { stopGateway(); } restartConnector(true); // Turn on jSLP, dont use GW } break; default: // Do nothing, keep using jSLP / GW or not, as previous state break; } } mCurrentWIFI = newWifi; } else if (action.equals(AppConstants.ACTION_PCK_REG)) { // REGISTER message from scan service Log.v(TAG, "Action is REGISTER"); AndroidRegistry.register(intent.getStringExtra(AppConstants.ACTION_PCK_REG_X_ID), (GroundingParcel) intent .getParcelableExtra(AppConstants.ACTION_PCK_REG_X_PARCEL), intent.getIntExtra(AppConstants.ACTION_PCK_REG_X_TYPE, 0), MiddlewareService.this); } else if (action.equals(AppConstants.ACTION_PCK_UNREG)) { // UNREGISTER message from scan service Log.v(TAG, "Action is UNREGISTER"); AndroidRegistry.unregister(intent.getStringExtra(AppConstants.ACTION_PCK_UNREG_X_ID), intent.getIntExtra(AppConstants.ACTION_PCK_UNREG_X_TYPE, 0)); } else { // Not the right action yet (TODO check if from receivers) Log.v(TAG, "Action is... Not the right action yet"); } } else { // If (action=null) who? Log.v(TAG, "Action is none"); } } } }, TAG_THREAD_START).start(); return START_STICKY; }
From source file:cn.studyjams.s2.sj0132.bowenyan.mygirlfriend.nononsenseapps.notepad.data.receiver.NotificationHelper.java
/** * Fires notifications that have elapsed and sets an alarm to be woken at * the next notification.// www .j a va 2s . c o m * <p/> * If the intent action is ACTION_DELETE, will delete the notification with * the indicated ID, and cancel it from any active notifications. */ @Override public void onReceive(Context context, Intent intent) { if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction()) || Intent.ACTION_RUN.equals(intent.getAction())) { // Can't cancel anything. Just schedule and notify at end } else { // Always cancel cancelNotification(context, intent.getData()); if (Intent.ACTION_DELETE.equals(intent.getAction()) || ACTION_RESCHEDULE.equals(intent.getAction())) { // Just a notification cn.studyjams.s2.sj0132.bowenyan.mygirlfriend.nononsenseapps.notepad.data.model.sql.Notification .deleteOrReschedule(context, intent.getData()); } else if (ACTION_SNOOZE.equals(intent.getAction())) { // msec/sec * sec/min * 30 long delay30min = 1000 * 60 * 30; final Calendar now = Calendar.getInstance(); cn.studyjams.s2.sj0132.bowenyan.mygirlfriend.nononsenseapps.notepad.data.model.sql.Notification .setTime(context, intent.getData(), delay30min + now.getTimeInMillis()); } else if (ACTION_COMPLETE.equals(intent.getAction())) { // Complete note Task.setCompletedSynced(context, true, intent.getLongExtra(ARG_TASKID, -1)); // Delete notifications with the same task id cn.studyjams.s2.sj0132.bowenyan.mygirlfriend.nononsenseapps.notepad.data.model.sql.Notification .removeWithTaskIdsSynced(context, intent.getLongExtra(ARG_TASKID, -1)); } } notifyPast(context, true); scheduleNext(context); }
From source file:org.sipdroid.sipua.ui.Receiver.java
@Override public void onReceive(Context context, Intent intent) { String intentAction = intent.getAction(); if (!Sipdroid.on(context)) return;//from w w w. j a v a 2 s . c o m if (!Sipdroid.release) Log.i("SipUA:", intentAction); if (mContext == null) mContext = context; if (intentAction.equals(Intent.ACTION_BOOT_COMPLETED)) { on_vpn(false); engine(context).register(); } else if (intentAction.equals(ConnectivityManager.CONNECTIVITY_ACTION) || intentAction.equals(ACTION_EXTERNAL_APPLICATIONS_AVAILABLE) || intentAction.equals(ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE) || intentAction.equals(Intent.ACTION_PACKAGE_REPLACED)) { engine(context).register(); } else if (intentAction.equals(ACTION_VPN_CONNECTIVITY) && intent.hasExtra("connection_state")) { String state = intent.getSerializableExtra("connection_state").toString(); if (state != null && on_vpn() != state.equals("CONNECTED")) { on_vpn(state.equals("CONNECTED")); for (SipProvider sip_provider : engine(context).sip_providers) if (sip_provider != null) sip_provider.haltConnections(); engine(context).register(); } } else if (intentAction.equals(ACTION_DATA_STATE_CHANGED)) { engine(context).registerMore(); } else if (intentAction.equals(ACTION_PHONE_STATE_CHANGED) && !intent.getBooleanExtra(context.getString(R.string.app_name), false)) { stopRingtone(); pstn_state = intent.getStringExtra("state"); pstn_time = SystemClock.elapsedRealtime(); if (pstn_state.equals("IDLE") && call_state != UserAgent.UA_STATE_IDLE) broadcastCallStateChanged(null, null); if (!pstn_state.equals("IDLE") && call_state == UserAgent.UA_STATE_INCALL) mHandler.sendEmptyMessageDelayed(MSG_HOLD, 5000); else if (!pstn_state.equals("IDLE") && (call_state == UserAgent.UA_STATE_INCOMING_CALL || call_state == UserAgent.UA_STATE_OUTGOING_CALL)) mHandler.sendEmptyMessageDelayed(MSG_HANGUP, 5000); else if (pstn_state.equals("IDLE")) { mHandler.removeMessages(MSG_HOLD); mHandler.removeMessages(MSG_HANGUP); if (call_state == UserAgent.UA_STATE_HOLD) mHandler.sendEmptyMessageDelayed(MSG_HOLD, 1000); } } else if (intentAction.equals(ACTION_DOCK_EVENT)) { docked = intent.getIntExtra(EXTRA_DOCK_STATE, -1) & 7; if (call_state == UserAgent.UA_STATE_INCALL) engine(mContext).speaker(speakermode()); } else if (intentAction.equals(ACTION_SCO_AUDIO_STATE_CHANGED)) { bluetooth = intent.getIntExtra(EXTRA_SCO_AUDIO_STATE, -1); progress(); RtpStreamSender.changed = true; } else if (intentAction.equals(Intent.ACTION_HEADSET_PLUG)) { headset = intent.getIntExtra("state", -1); if (call_state == UserAgent.UA_STATE_INCALL) engine(mContext).speaker(speakermode()); } else if (intentAction.equals(Intent.ACTION_SCREEN_ON)) { if (!PreferenceManager.getDefaultSharedPreferences(mContext).getBoolean( org.sipdroid.sipua.ui.Settings.PREF_OWNWIFI, org.sipdroid.sipua.ui.Settings.DEFAULT_OWNWIFI)) alarm(0, OwnWifi.class); } else if (intentAction.equals(Intent.ACTION_USER_PRESENT)) { mHandler.sendEmptyMessageDelayed(MSG_ENABLE, 3000); } else if (intentAction.equals(Intent.ACTION_SCREEN_OFF)) { if (PreferenceManager.getDefaultSharedPreferences(mContext).getBoolean( org.sipdroid.sipua.ui.Settings.PREF_OWNWIFI, org.sipdroid.sipua.ui.Settings.DEFAULT_OWNWIFI)) { WifiManager wm = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE); WifiInfo wi = wm.getConnectionInfo(); if (wm.getWifiState() != WifiManager.WIFI_STATE_ENABLED || wi == null || wi.getSupplicantState() != SupplicantState.COMPLETED || wi.getIpAddress() == 0) alarm(2 * 60, OwnWifi.class); else alarm(15 * 60, OwnWifi.class); } if (SipdroidEngine.pwl != null) for (PowerManager.WakeLock pwl : SipdroidEngine.pwl) if (pwl != null && pwl.isHeld()) { pwl.release(); pwl.acquire(); } } else if (intentAction.equals(WifiManager.WIFI_STATE_CHANGED_ACTION)) { if (PreferenceManager.getDefaultSharedPreferences(mContext).getBoolean( org.sipdroid.sipua.ui.Settings.PREF_SELECTWIFI, org.sipdroid.sipua.ui.Settings.DEFAULT_SELECTWIFI)) mHandler.sendEmptyMessageDelayed(MSG_SCAN, 3000); } else if (intentAction.equals(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION)) { if (SystemClock.uptimeMillis() > lastscan + 45000 && PreferenceManager.getDefaultSharedPreferences(mContext).getBoolean( org.sipdroid.sipua.ui.Settings.PREF_SELECTWIFI, org.sipdroid.sipua.ui.Settings.DEFAULT_SELECTWIFI)) { WifiManager wm = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE); WifiInfo wi = wm.getConnectionInfo(); String activeSSID = null; if (wi != null) activeSSID = wi.getSSID(); if (activeSSID != null && (activeSSID.length() == 0 || activeSSID.equals("0x"))) activeSSID = null; List<ScanResult> mScanResults = wm.getScanResults(); List<WifiConfiguration> configurations = wm.getConfiguredNetworks(); if (configurations != null) { WifiConfiguration bestconfig = null, maxconfig = null, activeconfig = null; for (final WifiConfiguration config : configurations) { if (maxconfig == null || config.priority > maxconfig.priority) { maxconfig = config; } if (config.SSID != null && (config.SSID.equals("\"" + activeSSID + "\"") || config.SSID.equals(activeSSID))) activeconfig = config; } ScanResult bestscan = null, activescan = null; if (mScanResults != null) for (final ScanResult scan : mScanResults) { for (final WifiConfiguration config : configurations) { if (config.SSID != null && config.SSID.equals("\"" + scan.SSID + "\"")) { if (bestscan == null || scan.level > bestscan.level) { bestscan = scan; bestconfig = config; } if (config == activeconfig) activescan = scan; } } } if (activescan != null) System.out.println("debug wifi asu(active)" + asu(activescan)); if (bestconfig != null && (activeconfig == null || bestconfig.priority != activeconfig.priority) && asu(bestscan) > asu(activescan) * 1.5 && /* (activeSSID == null || activescan != null) && */ asu(bestscan) > 22) { if (!Sipdroid.release) Log.i("SipUA:", "changing to " + bestconfig.SSID); if (activeSSID == null || !activeSSID.equals(bestscan.SSID)) wm.disconnect(); bestconfig.priority = maxconfig.priority + 1; wm.updateNetwork(bestconfig); wm.enableNetwork(bestconfig.networkId, true); wm.saveConfiguration(); if (activeSSID == null || !activeSSID.equals(bestscan.SSID)) wm.reconnect(); lastscan = SystemClock.uptimeMillis(); } else if (activescan != null && asu(activescan) < 15) { wm.disconnect(); wm.disableNetwork(activeconfig.networkId); wm.saveConfiguration(); } } } } }
From source file:com.android.calendar.alerts.AlertService.java
void processMessage(Message msg) { Bundle bundle = (Bundle) msg.obj;// w w w .ja v a 2s. c om // On reboot, update the notification bar with the contents of the // CalendarAlerts table. String action = bundle.getString("action"); if (DEBUG) { Log.d(TAG, bundle.getLong(android.provider.CalendarContract.CalendarAlerts.ALARM_TIME) + " Action = " + action); } // Some OEMs had changed the provider's EVENT_REMINDER broadcast to their own event, // which broke our unbundled app's reminders. So we added backup alarm scheduling to the // app, but we know we can turn it off if we ever receive the EVENT_REMINDER broadcast. boolean providerReminder = action.equals(android.provider.CalendarContract.ACTION_EVENT_REMINDER); if (providerReminder) { if (sReceivedProviderReminderBroadcast == null) { sReceivedProviderReminderBroadcast = Utils.getSharedPreference(this, PROVIDER_REMINDER_PREF_KEY, false); } if (!sReceivedProviderReminderBroadcast) { sReceivedProviderReminderBroadcast = true; Log.d(TAG, "Setting key " + PROVIDER_REMINDER_PREF_KEY + " to: true"); Utils.setSharedPreference(this, PROVIDER_REMINDER_PREF_KEY, true); } } if (providerReminder || action.equals(Intent.ACTION_PROVIDER_CHANGED) || action.equals(android.provider.CalendarContract.ACTION_EVENT_REMINDER) || action.equals(AlertReceiver.EVENT_REMINDER_APP_ACTION) || action.equals(Intent.ACTION_LOCALE_CHANGED)) { // b/7652098: Add a delay after the provider-changed event before refreshing // notifications to help issue with the unbundled app installed on HTC having // stale notifications. if (action.equals(Intent.ACTION_PROVIDER_CHANGED)) { try { Thread.sleep(5000); } catch (Exception e) { // Ignore. } } updateAlertNotification(this); } else if (action.equals(Intent.ACTION_BOOT_COMPLETED)) { // The provider usually initiates this setting up of alarms on startup, // but there was a bug (b/7221716) where a race condition caused this step to be // skipped, resulting in missed alarms. This is a stopgap to minimize this bug // for devices that don't have the provider fix, by initiating this a 2nd time here. // However, it would still theoretically be possible to hit the race condition // the 2nd time and still miss alarms. // // TODO: Remove this when the provider fix is rolled out everywhere. Intent intent = new Intent(); intent.setClass(this, InitAlarmsService.class); startService(intent); } else if (action.equals(Intent.ACTION_TIME_CHANGED)) { doTimeChanged(); } else if (action.equals(AlertReceiver.ACTION_DISMISS_OLD_REMINDERS)) { dismissOldAlerts(this); } else { Log.w(TAG, "Invalid action: " + action); } // Schedule the alarm for the next upcoming reminder, if not done by the provider. if (sReceivedProviderReminderBroadcast == null || !sReceivedProviderReminderBroadcast) { Log.d(TAG, "Scheduling next alarm with AlarmScheduler. " + "sEventReminderReceived: " + sReceivedProviderReminderBroadcast); AlarmScheduler.scheduleNextAlarm(this); } }