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:co.vanir.indecentxposure.IndecentXposure.java
@Override public void onReceive(Context context, Intent intent) { if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) { start(context);/*from www. j av a 2 s .co m*/ } else if (intent.getAction().equals(intent.ACTION_PACKAGE_ADDED) || intent.getAction().equals(intent.ACTION_PACKAGE_REMOVED)) { //handle package install/uninstall all smart-like if (intent.getData() == null || intent.getData().getScheme() == null || !intent.getData().getScheme().equals("package") || intent.getData().getEncodedSchemeSpecificPart() == null) { Log.e(TAG, "Received garbage package data in intent"); return; } //are you my mommy? if (!intent.getData().getEncodedSchemeSpecificPart().equals(SerialOffender.getPackageName())) { Log.v(TAG, "Ignoring irrelevant package addition/removal"); return; } if (intent.getAction().equals(intent.ACTION_PACKAGE_ADDED)) { //sound the alarm IndecentXposure.notify(context, "package installed -- and something about the consequences of that"); } else { //all is well that ends well IndecentXposure.cancel(context); if (SerialOffender.getIgnoredState(context)) { //reload, in case xposed gets reinstalled SerialOffender.setIgnoredState(context, false); } } } else { //if it's not boot, and not pack add/remove, then the user must've chosen the "ignore risks" option on the notification Log.i(TAG, "Received ignore request"); SerialOffender.setIgnoredState(context, true); IndecentXposure.cancel(context); } }
From source file:com.android.usbtuner.UsbInputController.java
@Override public void onReceive(Context context, Intent intent) { if (DEBUG)/* www .j ava 2 s . co m*/ Log.d(TAG, "Broadcast intent received:" + intent); if (!Features.USB_TUNER.isEnabled(context)) { enableUsbTunerTvInputService(context, false); return; } switch (intent.getAction()) { case Intent.ACTION_BOOT_COMPLETED: case UsbManager.ACTION_USB_DEVICE_ATTACHED: case UsbManager.ACTION_USB_DEVICE_DETACHED: // Tuner is supported on MNC and later version only. boolean enabled = IS_MNC_OR_LATER && isTunerConnected(context); mHandler.removeMessages(MSG_ENABLE_INPUT_SERVICE); if (enabled) { // Need to check if DVB driver is accessible. Since the driver creation // could be happen after the USB event, delay the checking by // DVB_DRIVER_CHECK_DELAY_MS. mHandler.sendMessageDelayed(mHandler.obtainMessage(MSG_ENABLE_INPUT_SERVICE, context), DVB_DRIVER_CHECK_DELAY_MS); } else { enableUsbTunerTvInputService(context, false); } break; } }
From source file:eu.faircode.adblocker.Receiver.java
@Override public void onReceive(final Context context, Intent intent) { Log.i(TAG, "Received " + intent); Util.logExtras(intent);//from w w w .j a v a 2 s . c o m if (Intent.ACTION_PACKAGE_ADDED.equals(intent.getAction())) { // Application added if (!intent.getBooleanExtra(Intent.EXTRA_REPLACING, false)) { // Show notification if (IAB.isPurchased(ActivityPro.SKU_NOTIFY, context)) { int uid = intent.getIntExtra(Intent.EXTRA_UID, -1); notifyNewApplication(uid, context); } } } else if (Intent.ACTION_PACKAGE_REMOVED.equals(intent.getAction())) { // Application removed Rule.clearCache(context); if (intent.getBooleanExtra(Intent.EXTRA_DATA_REMOVED, false)) { // Remove settings String packageName = intent.getData().getSchemeSpecificPart(); Log.i(TAG, "Deleting settings package=" + packageName); context.getSharedPreferences("wifi", Context.MODE_PRIVATE).edit().remove(packageName).apply(); context.getSharedPreferences("other", Context.MODE_PRIVATE).edit().remove(packageName).apply(); context.getSharedPreferences("apply", Context.MODE_PRIVATE).edit().remove(packageName).apply(); context.getSharedPreferences("screen_wifi", Context.MODE_PRIVATE).edit().remove(packageName) .apply(); context.getSharedPreferences("screen_other", Context.MODE_PRIVATE).edit().remove(packageName) .apply(); context.getSharedPreferences("roaming", Context.MODE_PRIVATE).edit().remove(packageName).apply(); context.getSharedPreferences("notify", Context.MODE_PRIVATE).edit().remove(packageName).apply(); int uid = intent.getIntExtra(Intent.EXTRA_UID, 0); if (uid > 0) { NotificationManagerCompat.from(context).cancel(uid); // installed notification NotificationManagerCompat.from(context).cancel(uid + 10000); // access notification } } } else { // Upgrade settings upgrade(true, context); // Start service SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); try { if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) { if (prefs.getBoolean("enabled", false) || prefs.getBoolean("show_stats", false)) ServiceSinkhole.start("receiver", context); } else if (Intent.ACTION_MY_PACKAGE_REPLACED.equals(intent.getAction())) { if (prefs.getBoolean("enabled", false)) ServiceSinkhole.start("receiver", context); else if (prefs.getBoolean("show_stats", false)) ServiceSinkhole.run("receiver", context); } } catch (Throwable ex) { Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); Util.sendCrashReport(ex, context); } if (Util.isInteractive(context)) ServiceSinkhole.reloadStats("receiver", context); } }
From source file:com.zhengde163.netguard.Receiver.java
@Override public void onReceive(final Context context, Intent intent) { Log.i(TAG, "Received " + intent); Util.logExtras(intent);/* www .j a va 2 s .c o m*/ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); if (Intent.ACTION_PACKAGE_ADDED.equals(intent.getAction())) { // Application added if (!intent.getBooleanExtra(Intent.EXTRA_REPLACING, false)) { // Show notification if (prefs.getBoolean("install", true)) { int uid = intent.getIntExtra(Intent.EXTRA_UID, -1); notifyNewApplication(uid, context); } } } else if (Intent.ACTION_PACKAGE_REMOVED.equals(intent.getAction())) { // Application removed Rule.clearCache(context); if (intent.getBooleanExtra(Intent.EXTRA_DATA_REMOVED, false)) { // Remove settings String packageName = intent.getData().getSchemeSpecificPart(); Log.i(TAG, "Deleting settings package=" + packageName); context.getSharedPreferences("wifi", Context.MODE_PRIVATE).edit().remove(packageName).apply(); context.getSharedPreferences("other", Context.MODE_PRIVATE).edit().remove(packageName).apply(); context.getSharedPreferences("apply", Context.MODE_PRIVATE).edit().remove(packageName).apply(); context.getSharedPreferences("screen_wifi", Context.MODE_PRIVATE).edit().remove(packageName) .apply(); context.getSharedPreferences("screen_other", Context.MODE_PRIVATE).edit().remove(packageName) .apply(); context.getSharedPreferences("roaming", Context.MODE_PRIVATE).edit().remove(packageName).apply(); context.getSharedPreferences("notify", Context.MODE_PRIVATE).edit().remove(packageName).apply(); int uid = intent.getIntExtra(Intent.EXTRA_UID, 0); if (uid > 0) { DatabaseHelper.getInstance(context).clearAccess(uid, false); NotificationManagerCompat.from(context).cancel(uid); // installed notification NotificationManagerCompat.from(context).cancel(uid + 10000); // access notification } } } else { // Upgrade settings upgrade(true, context); // Start service try { if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) { if (prefs.getBoolean("enabled", false) || prefs.getBoolean("show_stats", false)) ServiceSinkhole.start("receiver", context); } else if (Intent.ACTION_MY_PACKAGE_REPLACED.equals(intent.getAction())) { if (prefs.getBoolean("enabled", false)) ServiceSinkhole.start("receiver", context); else if (prefs.getBoolean("show_stats", false)) ServiceSinkhole.run("receiver", context); } } catch (Throwable ex) { Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); Util.sendCrashReport(ex, context); } if (Util.isInteractive(context)) ServiceSinkhole.reloadStats("receiver", context); } }
From source file:com.master.metehan.filtereagle.Receiver.java
@Override public void onReceive(final Context context, Intent intent) { Log.i(TAG, "Received " + intent); Util.logExtras(intent);//from www . j a v a 2s.c o m SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); if (Intent.ACTION_PACKAGE_ADDED.equals(intent.getAction())) { // Application added if (!intent.getBooleanExtra(Intent.EXTRA_REPLACING, false)) { // Show notification if (IAB.isPurchased(ActivityPro.SKU_NOTIFY, context) && prefs.getBoolean("install", true)) { int uid = intent.getIntExtra(Intent.EXTRA_UID, -1); notifyNewApplication(uid, context); } } } else if (Intent.ACTION_PACKAGE_REMOVED.equals(intent.getAction())) { // Application removed Rule.clearCache(context); if (intent.getBooleanExtra(Intent.EXTRA_DATA_REMOVED, false)) { // Remove settings String packageName = intent.getData().getSchemeSpecificPart(); Log.i(TAG, "Deleting settings package=" + packageName); context.getSharedPreferences("wifi", Context.MODE_PRIVATE).edit().remove(packageName).apply(); context.getSharedPreferences("other", Context.MODE_PRIVATE).edit().remove(packageName).apply(); context.getSharedPreferences("apply", Context.MODE_PRIVATE).edit().remove(packageName).apply(); context.getSharedPreferences("screen_wifi", Context.MODE_PRIVATE).edit().remove(packageName) .apply(); context.getSharedPreferences("screen_other", Context.MODE_PRIVATE).edit().remove(packageName) .apply(); context.getSharedPreferences("roaming", Context.MODE_PRIVATE).edit().remove(packageName).apply(); context.getSharedPreferences("notify", Context.MODE_PRIVATE).edit().remove(packageName).apply(); int uid = intent.getIntExtra(Intent.EXTRA_UID, 0); if (uid > 0) { DatabaseHelper.getInstance(context).clearAccess(uid, false); NotificationManagerCompat.from(context).cancel(uid); // installed notification NotificationManagerCompat.from(context).cancel(uid + 10000); // access notification } } } else { // Upgrade settings upgrade(true, context); // Start service try { if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) { if (prefs.getBoolean("enabled", false) || prefs.getBoolean("show_stats", false)) ServiceSinkhole.start("receiver", context); } else if (Intent.ACTION_MY_PACKAGE_REPLACED.equals(intent.getAction())) { if (prefs.getBoolean("enabled", false)) ServiceSinkhole.start("receiver", context); else if (prefs.getBoolean("show_stats", false)) ServiceSinkhole.run("receiver", context); } } catch (Throwable ex) { Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); Util.sendCrashReport(ex, context); } if (Util.isInteractive(context)) ServiceSinkhole.reloadStats("receiver", context); } }
From source file:com.magnet.mmx.client.MMXWakeupIntentService.java
@Override protected void onHandleIntent(Intent intent) { //verify the message is a wakeup message String action = intent.getAction(); if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "onHandleIntent(): action=" + action); }//from ww w . j av a 2 s .c om if ("com.google.android.c2dm.intent.RECEIVE".equals(action)) { GooglePlayServicesWrapper playServicesWrapper = GooglePlayServicesWrapper.getInstance(this); int messageType = playServicesWrapper.getGcmMessageType(intent); if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "onHandleIntent(): Received message type: " + messageType); } switch (messageType) { case GooglePlayServicesWrapper.GCM_MESSAGE_TYPE_SEND_ERROR: case GooglePlayServicesWrapper.GCM_MESSAGE_TYPE_DELETED: case GooglePlayServicesWrapper.GCM_MESSAGE_TYPE_SEND_EVENT: Log.w(TAG, "onHandleIntent(): Message type is not handled: " + messageType); break; case GooglePlayServicesWrapper.GCM_MESSAGE_TYPE_MESSAGE: //parse the GCM message if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "onHandleIntent(): Handling GCM message. extras: " + intent.getExtras()); } Bundle extras = intent.getExtras(); String msg = extras.getString("msg"); boolean isMmxHandle = false; if (msg != null) { try { PushMessage pushMessage = PushMessage.decode(msg, MMXTypeMapper.getInstance()); isMmxHandle = handleMMXInternalPush(pushMessage); Log.d(TAG, "isMmxHandle=" + isMmxHandle + ", pushMsg=" + pushMessage); } catch (UnknownTypeException ex) { //This is not an internal MMX message type Log.i(TAG, "onHandleIntent() forwarding intent to application"); } catch (Throwable e) { Log.e(TAG, "onHandleIntent() generic exception caught while parsing GCM payload.", e); } } if (!isMmxHandle) { MMXClient.handleWakeup(this, intent); } break; } MMXGcmBroadcastReceiver.completeWakefulIntent(intent); } else { if (Intent.ACTION_BOOT_COMPLETED.equals(action) || MMXClient.ACTION_WAKEUP.equals(action)) { MMXClient.handleWakeup(this, intent); } else { //log and do nothing Log.w(TAG, "onHandleIntent(): Unsupported action: " + action); } MMXWakeupReceiver.completeWakefulIntent(intent); } }
From source file:org.dmfs.tasks.notification.NotificationUpdaterService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { String intentAction = intent.getAction(); if (intentAction != null) { switch (intentAction) { case ACTION_PIN_TASK: // nothing special to do right now break; case ACTION_PINNED_TASK_START: updateNotifications(true, true, true); delayedCancelHeadsUpNotification(); break; case ACTION_PINNED_TASK_DUE: updateNotifications(true, true, true); delayedCancelHeadsUpNotification(); break; case ACTION_COMPLETE: if (intent.hasExtra(NotificationActionUtils.EXTRA_NOTIFICATION_ACTION)) { resolveUndoAction(intent); break; }/*from w w w.jav a 2 s .co m*/ resolveCompleteAction(intent); break; case ACTION_UNPIN: resolveUnpinAction(intent); break; case ACTION_DELAY_1D: case ACTION_DELAY_1H: resolveDelayAction(intent); break; case NotificationActionUtils.ACTION_UNDO: case NotificationActionUtils.ACTION_DESTRUCT: case NotificationActionUtils.ACTION_UNDO_TIMEOUT: resolveUndoAction(intent); break; case Intent.ACTION_BOOT_COMPLETED: case Intent.ACTION_REBOOT: case TaskNotificationHandler.ACTION_FASTBOOT: updateNotifications(true, false, false); break; case Intent.ACTION_DATE_CHANGED: case Intent.ACTION_TIME_CHANGED: case Intent.ACTION_TIMEZONE_CHANGED: case ACTION_NEXT_DAY: updateNextDayAlarm(); updateNotifications(false, false, false); break; case ACTION_CANCEL_HEADUP_NOTIFICATION: updateNotifications(false, false, false); break; default: updateNotifications(false, false, false); break; } } // check if the service needs to kept alive if (mTasksToPin == null || mTasksToPin.isEmpty()) { this.stopSelf(); } return Service.START_NOT_STICKY; }
From source file:nu.yona.app.utils.AppUtils.java
/** * This will register receiver for different events like screen on-off, boot, connectivity etc. * * @param context the context// w ww . j a v a2 s . co m */ public static void registerReceiver(Context context) { loge(TAG, "Register Receiver"); IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_SCREEN_ON); filter.addAction(Intent.ACTION_SCREEN_OFF); filter.addAction(Intent.ACTION_BOOT_COMPLETED); filter.addAction(AppConstant.RESTART_DEVICE); filter.addAction(AppConstant.RESTART_VPN); filter.addAction(PowerManager.ACTION_DEVICE_IDLE_MODE_CHANGED); context.registerReceiver(receiver, filter); }
From source file:com.ota.updates.receivers.AppReceiver.java
@Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); Bundle extras = intent.getExtras();/*from w ww .java2 s .c om*/ long mRomDownloadID = Preferences.getDownloadID(context); if (action.equals(DownloadManager.ACTION_DOWNLOAD_COMPLETE)) { long id = extras.getLong(DownloadManager.EXTRA_DOWNLOAD_ID); boolean isAddonDownload = false; int keyForAddonDownload = 0; Set<Integer> set = OtaUpdates.getAddonDownloadKeySet(); Iterator<Integer> iterator = set.iterator(); while (iterator.hasNext() && isAddonDownload != true) { int nextValue = iterator.next(); if (id == OtaUpdates.getAddonDownload(nextValue)) { isAddonDownload = true; keyForAddonDownload = nextValue; if (DEBUGGING) { Log.d(TAG, "Checking ID " + nextValue); } } } if (isAddonDownload) { DownloadManager downloadManager = (DownloadManager) context .getSystemService(Context.DOWNLOAD_SERVICE); DownloadManager.Query query = new DownloadManager.Query(); query.setFilterById(id); Cursor cursor = downloadManager.query(query); // it shouldn't be empty, but just in case if (!cursor.moveToFirst()) { if (DEBUGGING) Log.e(TAG, "Addon Download Empty row"); return; } int statusIndex = cursor.getColumnIndex(DownloadManager.COLUMN_STATUS); if (DownloadManager.STATUS_SUCCESSFUL != cursor.getInt(statusIndex)) { if (DEBUGGING) Log.w(TAG, "Download Failed"); Log.d(TAG, "Removing Addon download with id " + keyForAddonDownload); OtaUpdates.removeAddonDownload(keyForAddonDownload); AddonActivity.AddonsArrayAdapter.updateProgress(keyForAddonDownload, 0, true); AddonActivity.AddonsArrayAdapter.updateButtons(keyForAddonDownload, false); return; } else { if (DEBUGGING) Log.v(TAG, "Download Succeeded"); Log.d(TAG, "Removing Addon download with id " + keyForAddonDownload); OtaUpdates.removeAddonDownload(keyForAddonDownload); AddonActivity.AddonsArrayAdapter.updateButtons(keyForAddonDownload, true); return; } } else { if (DEBUGGING) Log.v(TAG, "Receiving " + mRomDownloadID); if (id != mRomDownloadID) { if (DEBUGGING) Log.v(TAG, "Ignoring unrelated non-ROM download " + id); return; } DownloadManager downloadManager = (DownloadManager) context .getSystemService(Context.DOWNLOAD_SERVICE); DownloadManager.Query query = new DownloadManager.Query(); query.setFilterById(id); Cursor cursor = downloadManager.query(query); // it shouldn't be empty, but just in case if (!cursor.moveToFirst()) { if (DEBUGGING) Log.e(TAG, "Rom download Empty row"); return; } int statusIndex = cursor.getColumnIndex(DownloadManager.COLUMN_STATUS); if (DownloadManager.STATUS_SUCCESSFUL != cursor.getInt(statusIndex)) { if (DEBUGGING) Log.w(TAG, "Download Failed"); Preferences.setDownloadFinished(context, false); if (Utils.isLollipop()) { AvailableActivity.setupMenuToolbar(context); // Reset options menu } else { AvailableActivity.invalidateMenu(); } return; } else { if (DEBUGGING) Log.v(TAG, "Download Succeeded"); Preferences.setDownloadFinished(context, true); AvailableActivity.setupProgress(context); if (Utils.isLollipop()) { AvailableActivity.setupMenuToolbar(context); // Reset options menu } else { AvailableActivity.invalidateMenu(); } return; } } } if (action.equals(DownloadManager.ACTION_NOTIFICATION_CLICKED)) { long[] ids = extras.getLongArray(DownloadManager.EXTRA_NOTIFICATION_CLICK_DOWNLOAD_IDS); for (long id : ids) { if (id != mRomDownloadID) { if (DEBUGGING) Log.v(TAG, "mDownloadID is " + mRomDownloadID + " and ID is " + id); return; } else { Intent i = new Intent(context, AvailableActivity.class); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(i); } } } if (action.equals(MANIFEST_CHECK_BACKGROUND)) { if (DEBUGGING) Log.d(TAG, "Receiving background check confirmation"); boolean updateAvailable = RomUpdate.getUpdateAvailability(context); String filename = RomUpdate.getFilename(context); if (updateAvailable) { Utils.setupNotification(context, filename); Utils.scheduleNotification(context, !Preferences.getBackgroundService(context)); } } if (action.equals(START_UPDATE_CHECK)) { if (DEBUGGING) Log.d(TAG, "Update check started"); new LoadUpdateManifest(context, false).execute(); } if (action.equals(Intent.ACTION_BOOT_COMPLETED)) { if (DEBUGGING) { Log.d(TAG, "Boot received"); } boolean backgroundCheck = Preferences.getBackgroundService(context); if (backgroundCheck) { if (DEBUGGING) Log.d(TAG, "Starting background check alarm"); Utils.scheduleNotification(context, !Preferences.getBackgroundService(context)); } } if (action.equals(IGNORE_RELEASE)) { if (DEBUGGING) { Log.d(TAG, "Ignore release"); } Preferences.setIgnoredRelease(context, Integer.toString(RomUpdate.getVersionNumber(context))); final NotificationManager mNotifyManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); Builder mBuilder = new NotificationCompat.Builder(context); mBuilder.setContentTitle(context.getString(R.string.main_release_ignored)) .setSmallIcon(R.drawable.ic_notif) .setContentIntent(PendingIntent.getActivity(context, 0, new Intent(), 0)); mNotifyManager.notify(NOTIFICATION_ID, mBuilder.build()); Handler h = new Handler(); long delayInMilliseconds = 1500; h.postDelayed(new Runnable() { public void run() { mNotifyManager.cancel(NOTIFICATION_ID); } }, delayInMilliseconds); } }
From source file:com.psiphon3.psiphonlibrary.UpgradeChecker.java
@Override public void onReceive(Context context, Intent intent) { // This service runs as a separate process, so it needs to initialize embedded values EmbeddedValues.initialize(context);//from www. java 2 s. c om // Make sure the alarm is created, regardless of which intent we received. createAlarm(context.getApplicationContext()); String action = intent.getAction(); if (action.equals(ALARM_INTENT_ACTION)) { log(context, R.string.upgrade_checker_alarm_intent_received, MyLog.Sensitivity.NOT_SENSITIVE, Log.WARN); if (!upgradeCheckNeeded(context)) { return; } checkForUpgrade(context); } else if (action.equals(UPGRADE_FILE_AVAILABLE_INTENT_ACTION)) { log(context, R.string.upgrade_checker_upgrade_file_available_intent_received, MyLog.Sensitivity.NOT_SENSITIVE, Log.WARN); // Create upgrade notification. User clicking the notification will trigger the install. UpgradeManager.UpgradeInstaller.notifyUpgrade(context.getApplicationContext()); } else if (action.equals(Intent.ACTION_BOOT_COMPLETED)) { log(context, R.string.upgrade_checker_boot_completed_intent_received, MyLog.Sensitivity.NOT_SENSITIVE, Log.WARN); // Pass. We created the alarm above, so nothing else to do (until the alarm runs). } else if (action.equals(CREATE_ALARM_INTENT_ACTION)) { log(context, R.string.upgrade_checker_create_alarm_intent_received, MyLog.Sensitivity.NOT_SENSITIVE, Log.WARN); // Pass. We created the alarm above, so nothing else to do (until the alarm runs). } }