List of usage examples for android.content.pm PackageManager DONT_KILL_APP
int DONT_KILL_APP
To view the source code for android.content.pm PackageManager DONT_KILL_APP.
Click Source Link
From source file:org.mariotaku.twidere.app.TwidereApplication.java
@Override public void onCreate() { sInstance = this; if (BuildConfig.DEBUG) { StrictModeUtils.detectAllVmPolicy(); }/*from w ww . ja v a2 s . c o m*/ final SharedPreferences preferences = getSharedPreferences(); resetTheme(preferences); super.onCreate(); mProfileImageViewViewProcessor = new ProfileImageViewViewProcessor(); mFontFamilyTagProcessor = new FontFamilyTagProcessor(); ATE.registerViewProcessor(TabPagerIndicator.class, new TabPagerIndicatorViewProcessor()); ATE.registerViewProcessor(FloatingActionButton.class, new FloatingActionButtonViewProcessor()); ATE.registerViewProcessor(ActionBarContextView.class, new ActionBarContextViewViewProcessor()); ATE.registerViewProcessor(SwipeRefreshLayout.class, new SwipeRefreshLayoutViewProcessor()); ATE.registerViewProcessor(TimelineContentTextView.class, new TimelineContentTextViewViewProcessor()); ATE.registerViewProcessor(TextView.class, new TextViewViewProcessor()); ATE.registerViewProcessor(ImageView.class, new ImageViewViewProcessor()); ATE.registerViewProcessor(MaterialEditText.class, new MaterialEditTextViewProcessor()); ATE.registerViewProcessor(ProgressWheel.class, new ProgressWheelViewProcessor()); ATE.registerViewProcessor(ProfileImageView.class, mProfileImageViewViewProcessor); ATE.registerTagProcessor(OptimalLinkColorTagProcessor.TAG, new OptimalLinkColorTagProcessor()); ATE.registerTagProcessor(FontFamilyTagProcessor.TAG, mFontFamilyTagProcessor); ATE.registerTagProcessor(IconActionButtonTagProcessor.PREFIX_COLOR, new IconActionButtonTagProcessor(IconActionButtonTagProcessor.PREFIX_COLOR)); ATE.registerTagProcessor(IconActionButtonTagProcessor.PREFIX_COLOR_ACTIVATED, new IconActionButtonTagProcessor(IconActionButtonTagProcessor.PREFIX_COLOR_ACTIVATED)); ATE.registerTagProcessor(IconActionButtonTagProcessor.PREFIX_COLOR_DISABLED, new IconActionButtonTagProcessor(IconActionButtonTagProcessor.PREFIX_COLOR_DISABLED)); ATE.registerTagProcessor(ThemedMultiValueSwitch.PREFIX_TINT, new ThemedMultiValueSwitch.TintTagProcessor()); mProfileImageViewViewProcessor.setStyle(Utils.getProfileImageStyle(preferences)); mFontFamilyTagProcessor.setFontFamily(ThemeUtils.getThemeFontFamily(preferences)); final int themeColor = preferences.getInt(KEY_THEME_COLOR, ContextCompat.getColor(this, R.color.branding_color)); if (!ATE.config(this, VALUE_THEME_NAME_LIGHT).isConfigured()) { //noinspection WrongConstant ATE.config(this, VALUE_THEME_NAME_LIGHT).primaryColor(themeColor) .accentColor(ThemeUtils.getOptimalAccentColor(themeColor, Color.BLACK)).coloredActionBar(true) .coloredStatusBar(true).commit(); } if (!ATE.config(this, VALUE_THEME_NAME_DARK).isConfigured()) { ATE.config(this, VALUE_THEME_NAME_DARK) .accentColor(ThemeUtils.getOptimalAccentColor(themeColor, Color.WHITE)).coloredActionBar(false) .coloredStatusBar(true).statusBarColor(Color.BLACK).commit(); } if (!ATE.config(this, null).isConfigured()) { ATE.config(this, null).accentColor(ThemeUtils.getOptimalAccentColor(themeColor, Color.WHITE)) .coloredActionBar(false).coloredStatusBar(false).commit(); } initializeAsyncTask(); initDebugMode(); initBugReport(); mHandler = new Handler(); final PackageManager pm = getPackageManager(); final ComponentName main = new ComponentName(this, MainActivity.class); final ComponentName main2 = new ComponentName(this, MainHondaJOJOActivity.class); final boolean mainDisabled = pm .getComponentEnabledSetting(main) != PackageManager.COMPONENT_ENABLED_STATE_ENABLED; final boolean main2Disabled = pm .getComponentEnabledSetting(main2) != PackageManager.COMPONENT_ENABLED_STATE_ENABLED; final boolean noEntry = mainDisabled && main2Disabled; if (noEntry) { pm.setComponentEnabledSetting(main, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP); } else if (!mainDisabled) { pm.setComponentEnabledSetting(main2, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); } if (!Utils.isComposeNowSupported(this)) { final ComponentName assist = new ComponentName(this, AssistLauncherActivity.class); pm.setComponentEnabledSetting(assist, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); } migrateUsageStatisticsPreferences(); Utils.startRefreshServiceIfNeeded(this); DependencyHolder holder = DependencyHolder.get(this); registerActivityLifecycleCallbacks(holder.getActivityTracker()); final IntentFilter packageFilter = new IntentFilter(); packageFilter.addAction(Intent.ACTION_PACKAGE_CHANGED); packageFilter.addAction(Intent.ACTION_PACKAGE_ADDED); packageFilter.addAction(Intent.ACTION_PACKAGE_REMOVED); packageFilter.addAction(Intent.ACTION_PACKAGE_REPLACED); registerReceiver(new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { final int uid = intent.getIntExtra(Intent.EXTRA_UID, -1); final String[] packages = getPackageManager().getPackagesForUid(uid); DependencyHolder holder = DependencyHolder.get(context); final ExternalThemeManager manager = holder.getExternalThemeManager(); if (ArrayUtils.contains(packages, manager.getEmojiPackageName())) { manager.reloadEmojiPreferences(); } } }, packageFilter); }
From source file:com.hamradiocoin.wallet.ui.RequestCoinsFragment.java
private void handleLocalApp() { final ComponentName component = new ComponentName(activity, SendCoinsActivity.class); final PackageManager pm = activity.getPackageManager(); final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(determineBitcoinRequestStr(false))); // launch intent chooser with ourselves excluded pm.setComponentEnabledSetting(component, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); startActivity(intent);// w ww. j av a 2s . c om pm.setComponentEnabledSetting(component, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP); activity.finish(); }
From source file:com.cyanogenmod.account.ui.SetupWizardActivity.java
private void disableSetupWizards(Intent intent) { final PackageManager pm = getPackageManager(); final List<ResolveInfo> resolveInfos = pm.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); for (ResolveInfo info : resolveInfos) { if (GOOGLE_SETUPWIZARD_PACKAGE.equals(info.activityInfo.packageName)) { final ComponentName componentName = new ComponentName(info.activityInfo.packageName, info.activityInfo.name); pm.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); }/* w w w . j a va2s . c o m*/ } pm.setComponentEnabledSetting(getComponentName(), PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); }
From source file:com.yacorso.nowaste.views.activities.DrawerActivity.java
/** * Enable every day local notification/*from ww w .ja v a 2s . co m*/ */ private void enableNotificationReceiver() { Context context = getApplicationContext(); ComponentName receiver = new ComponentName(context, BootCompletedReceiver.class); PackageManager pm = context.getPackageManager(); pm.setComponentEnabledSetting(receiver, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP); Intent serviceIntent = new Intent(context, NotificationService.class); context.stopService(serviceIntent); AlarmReceiver alarmReceiver = new AlarmReceiver(); alarmReceiver.setAlarm(context); }
From source file:com.android.tv.TvApplication.java
/** * Checks the input counts and enable/disable TvActivity. Also updates the input list in * {@link SetupUtils}./*from w ww .j a va 2 s . c om*/ * * @param calledByTunerServiceChanged true if it is called when UsbTunerTvInputService * is enabled or disabled. * @param tunerServiceEnabled it's available only when calledByTunerServiceChanged is true. * @param dontKillApp when TvActivity is enabled or disabled by this method, the app restarts * by default. But, if dontKillApp is true, the app won't restart. */ public void handleInputCountChanged(boolean calledByTunerServiceChanged, boolean tunerServiceEnabled, boolean dontKillApp) { TvInputManager inputManager = (TvInputManager) getSystemService(Context.TV_INPUT_SERVICE); boolean enable = (calledByTunerServiceChanged && tunerServiceEnabled) || Features.UNHIDE.isEnabled(TvApplication.this); if (!enable) { List<TvInputInfo> inputs = inputManager.getTvInputList(); boolean skipTunerInputCheck = false; // Enable the TvActivity only if there is at least one tuner type input. if (!skipTunerInputCheck) { for (TvInputInfo input : inputs) { if (calledByTunerServiceChanged && !tunerServiceEnabled && UsbTunerTvInputService.getInputId(this).equals(input.getId())) { continue; } if (input.getType() == TvInputInfo.TYPE_TUNER) { enable = true; break; } } } if (DEBUG) Log.d(TAG, "Enable MainActivity: " + enable); } PackageManager packageManager = getPackageManager(); ComponentName name = new ComponentName(this, TvActivity.class); int newState = enable ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED : PackageManager.COMPONENT_ENABLED_STATE_DISABLED; if (packageManager.getComponentEnabledSetting(name) != newState) { packageManager.setComponentEnabledSetting(name, newState, dontKillApp ? PackageManager.DONT_KILL_APP : 0); } SetupUtils.getInstance(TvApplication.this).onInputListUpdated(inputManager); }
From source file:org.hopestarter.wallet.ui.RequestCoinsFragment.java
private void handleLocalApp() { final ComponentName component = new ComponentName(activity, SendCoinsActivity.class); final PackageManager pm = activity.getPackageManager(); final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(determineBitcoinRequestStr(false))); try {/*from www . j av a2 s.c o m*/ // launch intent chooser with ourselves excluded pm.setComponentEnabledSetting(component, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); startActivity(intent); } catch (final ActivityNotFoundException x) { new Toast(activity).longToast(R.string.request_coins_no_local_app_msg); } finally { pm.setComponentEnabledSetting(component, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP); } activity.finish(); }
From source file:com.google.android.apps.iosched.util.UIUtils.java
public static void enableDisableActivities(final Context context) { boolean isHoneycombTablet = isHoneycombTablet(context); PackageManager pm = context.getPackageManager(); // Enable/disable phone activities for (Class a : sPhoneActivities) { pm.setComponentEnabledSetting(new ComponentName(context, a), isHoneycombTablet ? PackageManager.COMPONENT_ENABLED_STATE_DISABLED : PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP); }//w w w. j a v a 2 s .c o m // Enable/disable tablet activities for (Class a : sTabletActivities) { pm.setComponentEnabledSetting(new ComponentName(context, a), isHoneycombTablet ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED : PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); } }
From source file:com.kyleszombathy.sms_scheduler.MessageAlarmReceiver.java
/** Method to set a new alarm * @param context The app context/*from w w w .j a v a 2 s. c o m*/ * @param timeToSend The Time to send the message (in Calendar format) * @param phoneNumberList String Arraylist of phone numbers * @param messageContent The content of the message you want to send * @param alarmNumber Provide an identifier for the alarm * @param nameList The list of names, corresponding with the phone numbers*/ public void createAlarm(Context context, Calendar timeToSend, ArrayList<String> phoneNumberList, String messageContent, int alarmNumber, ArrayList<String> nameList) { this.context = context; // Creates new alarm alarm = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); Intent intentAlarm = new Intent(context, MessageAlarmReceiver.class); // Add extras Bundle extras = new Bundle(); extras.putStringArrayList("pNum", phoneNumberList); extras.putString("message", messageContent); extras.putInt("alarmNumber", alarmNumber); extras.putStringArrayList("nameList", nameList); intentAlarm.putExtras(extras); // Set alarm pendingIntent = PendingIntent.getBroadcast(context, alarmNumber, intentAlarm, PendingIntent.FLAG_UPDATE_CURRENT); alarm.set(AlarmManager.RTC_WAKEUP, timeToSend.getTimeInMillis(), pendingIntent); // Enable {@code MessageBootReceiver} to automatically restart the alarm when the // device is rebooted. ComponentName receiver = new ComponentName(context, MessageBootReceiver.class); PackageManager pm = context.getPackageManager(); pm.setComponentEnabledSetting(receiver, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP); Log.i(TAG, "createAlarm: Alarm Created. alarmNumber: " + alarmNumber); }
From source file:com.cognizant.trumobi.em.Email.java
public static void setServicesEnabled(Context context, boolean enabled) { PackageManager pm = context.getPackageManager(); if (!enabled && pm.getComponentEnabledSetting(new ComponentName(context, EmMailService.class)) == PackageManager.COMPONENT_ENABLED_STATE_ENABLED) { /*//from ww w .j a v a 2 s . co m * If no accounts now exist but the service is still enabled we're * about to disable it so we'll reschedule to kill off any existing * alarms. */ EmMailService.actionReschedule(context); } pm.setComponentEnabledSetting(new ComponentName(context, EmMessageCompose.class), enabled ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED : PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); pm.setComponentEnabledSetting(new ComponentName(context, EmAccountShortcutPicker.class), enabled ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED : PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); pm.setComponentEnabledSetting(new ComponentName(context, EmMailService.class), enabled ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED : PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); if (enabled && pm.getComponentEnabledSetting(new ComponentName(context, EmMailService.class)) == PackageManager.COMPONENT_ENABLED_STATE_ENABLED) { /* * And now if accounts do exist then we've just enabled the service * and we want to schedule alarms for the new accounts. */ EmMailService.actionReschedule(context); } }
From source file:com.android.settingslib.drawer.SettingsDrawerActivity.java
public void setTileEnabled(ComponentName component, boolean enabled) { PackageManager pm = getPackageManager(); int state = pm.getComponentEnabledSetting(component); boolean isEnabled = state == PackageManager.COMPONENT_ENABLED_STATE_ENABLED; if (isEnabled != enabled || state == PackageManager.COMPONENT_ENABLED_STATE_DEFAULT) { if (enabled) { sTileBlacklist.remove(component); } else {//from w w w . j av a2 s . c o m sTileBlacklist.add(component); } pm.setComponentEnabledSetting(component, enabled ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED : PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); new CategoriesUpdater().execute(); } }