List of usage examples for android.content.pm PackageManager COMPONENT_ENABLED_STATE_DISABLED
int COMPONENT_ENABLED_STATE_DISABLED
To view the source code for android.content.pm PackageManager COMPONENT_ENABLED_STATE_DISABLED.
Click Source Link
From source file:com.github.michalbednarski.intentslab.editor.IntentEditorActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { super.onPrepareOptionsMenu(menu); {//from w w w . j av a 2 s . c o m MenuItem runIntentOption = menu.findItem(R.id.menu_run_intent); if (mComponentType == IntentEditorConstants.RESULT) { if (getIntent().getBooleanExtra(EXTRA_FORWARD_ABLE_RESULT, false)) { runIntentOption.setVisible(true).setTitle("setResult(); finish()"); } else { runIntentOption.setVisible(false); } } else { runIntentOption.setVisible(true).setTitle( IntentGeneralFragment.getMethodNamesArray(getResources(), mComponentType)[mMethodId]); } } menu.findItem(R.id.set_editor_result).setVisible(mGenericEditorMode); menu.findItem(R.id.detach_intent_filter).setVisible(mAttachedIntentFilters != null); menu.findItem(R.id.component_info).setVisible(mEditedIntent.getComponent() != null); menu.findItem(R.id.attach_intent_filter).setVisible(mEditedIntent.getComponent() != null); // Intent tracking options { boolean intentTrackerAvailable = isIntentTrackerAvailable(); MenuItem trackIntentOption = menu.findItem(R.id.track_intent); trackIntentOption.setVisible(intentTrackerAvailable); trackIntentOption.setEnabled(intentTrackerAvailable); trackIntentOption.setChecked(getIntentTracker() != null); } // "Disable interception" option menu.findItem(R.id.disable_interception).setVisible(isInterceptedIntent()).setEnabled( isInterceptedIntent() && getPackageManager().getComponentEnabledSetting(new ComponentName(this, IntentEditorInterceptedActivity.class)) != PackageManager.COMPONENT_ENABLED_STATE_DISABLED); return true; }
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); }//from ww w .java2 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: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 w w w. j a v a 2 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.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) { /*// ww w .j a v a 2 s . c o 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 ww w .j ava 2s .co 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(); } }
From source file:com.github.michalbednarski.intentslab.editor.IntentEditorActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { // Handle item selection switch (item.getItemId()) { case R.id.menu_run_intent: runIntent();/*from ww w. j a va 2 s. c o m*/ return true; case R.id.set_editor_result: updateIntent(); setResult(0, new Intent().putExtra(Editor.EXTRA_VALUE, mEditedIntent)); finish(); return true; case R.id.attach_intent_filter: { // We have specified component, just find IntentFilters for it final ComponentName componentName = mEditedIntent.getComponent(); ExtendedPackageInfo.getExtendedPackageInfo(this, componentName.getPackageName(), new ExtendedPackageInfo.Callback() { @Override public void onPackageInfoAvailable(ExtendedPackageInfo extendedPackageInfo) { try { setAttachedIntentFilters(extendedPackageInfo .getComponentInfo(componentName.getClassName()).intentFilters); Toast.makeText(IntentEditorActivity.this, R.string.intent_filter_attached, Toast.LENGTH_SHORT).show(); } catch (NullPointerException e) { Toast.makeText(IntentEditorActivity.this, R.string.no_intent_filters_found, Toast.LENGTH_SHORT).show(); } } }); } return true; case R.id.detach_intent_filter: clearAttachedIntentFilters(); return true; case R.id.component_info: { ComponentName component = mEditedIntent.getComponent(); startActivity(new Intent(this, SingleFragmentActivity.class) .putExtra(SingleFragmentActivity.EXTRA_FRAGMENT, ComponentInfoFragment.class.getName()) .putExtra(ComponentInfoFragment.ARG_PACKAGE_NAME, component.getPackageName()) .putExtra(ComponentInfoFragment.ARG_COMPONENT_NAME, component.getClassName()) .putExtra(ComponentInfoFragment.ARG_LAUNCHED_FROM_INTENT_EDITOR, true)); } return true; case R.id.save: { updateIntent(); SavedItemsDatabase.getInstance(this).saveIntent(this, mEditedIntent, mComponentType, mMethodId); } return true; case R.id.track_intent: { if (!item.isChecked()) { XIntentsLab xIntentsLab = XIntentsLabStatic.getInstance(); if (xIntentsLab.havePermission()) { createIntentTracker(); } else { try { startIntentSenderForResult( xIntentsLab.getRequestPermissionIntent(getPackageName()).getIntentSender(), REQUEST_CODE_REQUEST_INTENT_TRACKER_PERMISSION, null, 0, 0, 0); } catch (IntentSender.SendIntentException e) { e.printStackTrace(); // TODO: can we handle this? } } } else { removeIntentTracker(); } return true; } case R.id.disable_interception: getPackageManager().setComponentEnabledSetting( new ComponentName(this, IntentEditorInterceptedActivity.class), PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); Toast.makeText(this, R.string.interception_disabled, Toast.LENGTH_SHORT).show(); return true; default: return super.onOptionsItemSelected(item); } }
From source file:com.air.mobilebrowser.BrowserActivity.java
/** * Clear the setting for default home./* www . j a va 2 s. co m*/ */ private void clearHome() { PackageManager pm = getPackageManager(); ComponentName fauxHomeComponent = new ComponentName(getApplicationContext(), FauxHome.class); ComponentName homeComponent = new ComponentName(getApplicationContext(), BrowserActivity.class); pm.setComponentEnabledSetting(fauxHomeComponent, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP); pm.setComponentEnabledSetting(homeComponent, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP); pm.setComponentEnabledSetting(fauxHomeComponent, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); pm.setComponentEnabledSetting(homeComponent, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); }
From source file:com.air.mobilebrowser.BrowserActivity.java
/** * Cleanup everything that was changed./*from w w w . j a v a 2 s.c o m*/ */ public void cleanup() { stopService(new Intent(getApplicationContext(), ActivityWatchService.class)); //clear home and exit PackageManager pm = getPackageManager(); ComponentName fauxHomeComponent = new ComponentName(getApplicationContext(), FauxHome.class); ComponentName homeComponent = new ComponentName(getApplicationContext(), BrowserActivity.class); pm.setComponentEnabledSetting(fauxHomeComponent, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); pm.setComponentEnabledSetting(homeComponent, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); mAudioManager.setMicrophoneMute(OrigSettings.getInstance().isMicMuted()); String curKeyboard = KeyboardUtil.getKeyboardPackage(BrowserActivity.this.getContentResolver()); if (!curKeyboard.equals(OrigSettings.getInstance().getKeyboard())) { KeyboardUtil.showInputChangedExitDialog(this, new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { finish(); } }); } else { finish(); } }
From source file:com.ichi2.anki.PreferenceContext.java
/** * Code which is run when a SharedPreference change has been detected * @param prefs instance of SharedPreferences * @param key key in prefs which is being updated * @param listener PreferenceActivity of PreferenceFragment which is hosting the preference *//*from w w w . java 2 s.com*/ private void updatePreference(SharedPreferences prefs, String key, PreferenceContext listener) { try { PreferenceScreen screen = listener.getPreferenceScreen(); Preference pref = screen.findPreference(key); // Handle special cases switch (key) { case "timeoutAnswer": { CheckBoxPreference keepScreenOn = (CheckBoxPreference) screen.findPreference("keepScreenOn"); keepScreenOn.setChecked(((CheckBoxPreference) pref).isChecked()); break; } case LANGUAGE: closePreferences(); break; case "convertFenText": if (((CheckBoxPreference) pref).isChecked()) { ChessFilter.install(Hooks.getInstance(getApplicationContext())); } else { ChessFilter.uninstall(Hooks.getInstance(getApplicationContext())); } break; case "fixHebrewText": if (((CheckBoxPreference) pref).isChecked()) { HebrewFixFilter.install(Hooks.getInstance(getApplicationContext())); showDialog(DIALOG_HEBREW_FONT); } else { HebrewFixFilter.uninstall(Hooks.getInstance(getApplicationContext())); } break; case "showProgress": getCol().getConf().put("dueCounts", ((CheckBoxPreference) pref).isChecked()); getCol().setMod(); break; case "showEstimates": getCol().getConf().put("estTimes", ((CheckBoxPreference) pref).isChecked()); getCol().setMod(); break; case "newSpread": getCol().getConf().put("newSpread", Integer.parseInt(((ListPreference) pref).getValue())); getCol().setMod(); break; case "timeLimit": getCol().getConf().put("timeLim", ((NumberRangePreference) pref).getValue() * 60); getCol().setMod(); break; case "learnCutoff": getCol().getConf().put("collapseTime", ((NumberRangePreference) pref).getValue() * 60); getCol().setMod(); break; case "useCurrent": getCol().getConf().put("addToCur", ((ListPreference) pref).getValue().equals("0")); getCol().setMod(); break; case "dayOffset": { int hours = ((SeekBarPreference) pref).getValue(); Timestamp crtTime = new Timestamp(getCol().getCrt() * 1000); Calendar date = GregorianCalendar.getInstance(); date.setTimeInMillis(crtTime.getTime()); date.set(Calendar.HOUR_OF_DAY, hours); getCol().setCrt(date.getTimeInMillis() / 1000); getCol().setMod(); break; } case "minimumCardsDueForNotification": { ListPreference listpref = (ListPreference) screen.findPreference("minimumCardsDueForNotification"); if (listpref != null) { updateNotificationPreference(listpref); } break; } case "reportErrorMode": { String value = prefs.getString("reportErrorMode", ""); AnkiDroidApp.getInstance().setAcraReportingMode(value); break; } case "syncAccount": { SharedPreferences preferences = AnkiDroidApp.getSharedPrefs(getBaseContext()); String username = preferences.getString("username", ""); Preference syncAccount = screen.findPreference("syncAccount"); if (syncAccount != null) { if (TextUtils.isEmpty(username)) { syncAccount.setSummary(R.string.sync_account_summ_logged_out); } else { syncAccount.setSummary(getString(R.string.sync_account_summ_logged_in, username)); } } break; } case "providerEnabled": { ComponentName providerName = new ComponentName(this, "com.ichi2.anki.provider.CardContentProvider"); PackageManager pm = getPackageManager(); int state; if (((CheckBoxPreference) pref).isChecked()) { state = PackageManager.COMPONENT_ENABLED_STATE_ENABLED; Timber.i("AnkiDroid ContentProvider enabled by user"); } else { state = PackageManager.COMPONENT_ENABLED_STATE_DISABLED; Timber.i("AnkiDroid ContentProvider disabled by user"); } pm.setComponentEnabledSetting(providerName, state, PackageManager.DONT_KILL_APP); break; } } // Update the summary text to reflect new value updateSummary(pref); } catch (BadTokenException e) { Timber.e(e, "Preferences: BadTokenException on showDialog"); } catch (NumberFormatException | JSONException e) { throw new RuntimeException(); } }