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:co.carlosandresjimenez.android.gotit.notification.AlarmReceiver.java
/** * Cancels the alarm./*w w w .j av a2 s . c o m*/ * * @param context */ public void cancelAlarm(Context context) { // If the alarm has been set, cancel it. if (alarmMgr != null) { alarmIntent.cancel(); alarmMgr.cancel(alarmIntent); } mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); mNotificationManager.cancel(NOTIFICATION_ID); ComponentName receiver = new ComponentName(context, BootReceiver.class); PackageManager pm = context.getPackageManager(); pm.setComponentEnabledSetting(receiver, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); }
From source file:ru.glesik.wifireminders.AlarmService.java
public void stopAlarm() { AlarmManager alarmManager = (AlarmManager) this.getSystemService(Context.ALARM_SERVICE); Intent intent = new Intent(this, AlarmReceiver.class); PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, intent, 0); alarmManager.cancel(pendingIntent);//from w ww. j a va2s . c o m // Disable boot receiver ComponentName receiver = new ComponentName(this, BootReceiver.class); PackageManager pm = this.getPackageManager(); pm.setComponentEnabledSetting(receiver, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); }
From source file:com.github.michalbednarski.intentslab.StartActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.menu_settings: startActivity(new Intent(this, PrefsActivity.class)); return true; case R.id.interception: { final PackageManager packageManager = getPackageManager(); boolean enable = packageManager.getComponentEnabledSetting( mInterceptActivityComponentName) != PackageManager.COMPONENT_ENABLED_STATE_ENABLED; packageManager// w w w. ja v a 2 s .c om .setComponentEnabledSetting(mInterceptActivityComponentName, enable ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED : PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); Toast.makeText(this, enable ? getString(R.string.interception_enabled) : getString(R.string.interception_disabled), Toast.LENGTH_SHORT).show(); ActivityCompat.invalidateOptionsMenu(this); return true; } case R.id.system_services: (new SystemServicesDialog()).show(getSupportFragmentManager(), "systemServices"); return true; case R.id.provider_lab: startActivity(new Intent(StartActivity.this, AdvancedQueryActivity.class)); return true; } return false; }
From source file:co.edu.uniajc.vtf.ar.ARViewActivity.java
@Override protected void onPause() { super.onPause(); ComponentName loComponent = new ComponentName(this, NetworkStatusReceiver.class); this.getPackageManager().setComponentEnabledSetting(loComponent, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); LocationServices.FusedLocationApi.removeLocationUpdates(coGoogleApiClient, this); if (this.architectView != null) { this.architectView.onPause(); }/*from w w w . j a va2 s. co m*/ }
From source file:com.android.usbtuner.UsbInputController.java
/** * Enable/disable the component {@link UsbTunerTvInputService}. * * @param context {@link Context} instance * @param enabled {@code true} to enable the service; otherwise {@code false} *//*from ww w . j a va 2 s. c om*/ private void enableUsbTunerTvInputService(Context context, boolean enabled) { PackageManager pm = context.getPackageManager(); ComponentName USBTUNER = new ComponentName(context, UsbTunerTvInputService.class); // Don't kill app by enabling/disabling TvActivity. If LC is killed by enabling/disabling // TvActivity, the following pm.setComponentEnabledSetting doesn't work. ((TvApplication) context.getApplicationContext()).handleInputCountChanged(true, enabled, true); // Since PackageManager.DONT_KILL_APP delays the operation by 10 seconds // (PackageManagerService.BROADCAST_DELAY), we'd better avoid using it. It is used only // when the LiveChannels app is active since we don't want to kill the running app. int flags = TvApplication.getSingletons(context).getMainActivityWrapper().isCreated() ? PackageManager.DONT_KILL_APP : 0; int newState = enabled ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED : PackageManager.COMPONENT_ENABLED_STATE_DISABLED; if (newState != pm.getComponentEnabledSetting(USBTUNER)) { // Send/cancel the USB tuner TV input setup recommendation card. TunerSetupActivity.onTvInputEnabled(context, enabled); // Enable/disable the USB tuner TV input. pm.setComponentEnabledSetting(USBTUNER, newState, flags); if (DEBUG) Log.d(TAG, "Status updated:" + enabled); } if (enabled && BuildCompat.isAtLeastN()) { TvInputInfo info = mDvbDeviceAccessor.buildTvInputInfo(context); if (info != null) { Log.i(TAG, "TvInputInfo updated: " + info.toString()); ((TvInputManager) context.getSystemService(Context.TV_INPUT_SERVICE)).updateTvInputInfo(info); } } }
From source file:com.p3authentication.preferences.Prefs.java
@SuppressWarnings("deprecation") @Override//w w w .j av a 2 s. co m public void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); getActionBar().setDisplayHomeAsUpEnabled(true); addPreferencesFromResource(R.xml.pref); AccessPin = (EditTextPreference) getPreferenceManager().findPreference("KeypadKey"); final Preference ResetPreference = getPreferenceManager().findPreference("reset_data"); final Preference EULAPreference = getPreferenceManager().findPreference("eula"); final Preference AboutUsPreference = getPreferenceManager().findPreference("about_us"); final Preference UnlockAppsPreference = getPreferenceManager().findPreference("unlock_apps"); final Preference TouchTolerance = getPreferenceManager().findPreference("touch_tolerance"); final Preference RedownloadImage = getPreferenceManager().findPreference("redownload_images"); final Preference RateApp = getPreferenceManager().findPreference("rate_app"); final CheckBoxPreference GhostStatusPref = (CheckBoxPreference) getPreferenceManager() .findPreference("GhostStatus"); final CheckBoxPreference StartServicePref = (CheckBoxPreference) getPreferenceManager() .findPreference("startup_service"); final ListPreference patterntype = (ListPreference) getPreferenceManager().findPreference("PatternType"); final ListPreference PatternStealth = (ListPreference) getPreferenceManager() .findPreference("PatternStealth"); if (patterntype.getValue().toString().equals("No Pattern")) { PatternStealth.setEnabled(false); } else { PatternStealth.setEnabled(true); } if (GhostStatusPref.isChecked()) { AccessPin.setEnabled(true); } else { AccessPin.setEnabled(false); } AccessPin.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { // TODO Auto-generated method stub if (newValue.toString().trim().equals("")) { Toast.makeText(Prefs.this, "Your Custom PIN cannot be empty.", Toast.LENGTH_LONG).show(); return false; } else if (newValue.toString().length() < 5) { Toast.makeText(Prefs.this, "Your Custom PIN must be atleast 5 Digits.", Toast.LENGTH_LONG) .show(); return false; } Toast.makeText(Prefs.this, "Your Custom PIN is set.", Toast.LENGTH_LONG).show(); return true; } }); GhostStatusPref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { if (newValue.toString().equals("true")) { hideLauncherIcon(); Toast.makeText(Prefs.this, "P3 hidden from App Menu", Toast.LENGTH_SHORT).show(); } else { showLauncherIcon(); Toast.makeText(Prefs.this, "P3 visible on App Menu", Toast.LENGTH_SHORT).show(); } return true; } }); StartServicePref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { if (newValue.toString().equals("true")) { ComponentName receiver = new ComponentName(Prefs.this, Startup.class); PackageManager pm = getPackageManager(); pm.setComponentEnabledSetting(receiver, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP); } else { ComponentName receiver = new ComponentName(Prefs.this, Startup.class); PackageManager pm = getPackageManager(); pm.setComponentEnabledSetting(receiver, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); } return true; } }); patterntype.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { // TODO Auto-generated method stub if (!newValue.toString().equals("No Pattern")) { PatternStealth.setEnabled(true); } else { PatternStealth.setEnabled(false); } return true; } }); ResetPreference.setOnPreferenceClickListener(this); UnlockAppsPreference.setOnPreferenceClickListener(this); TouchTolerance.setOnPreferenceClickListener(this); RedownloadImage.setOnPreferenceClickListener(this); RateApp.setOnPreferenceClickListener(this); AboutUsPreference.setOnPreferenceClickListener(this); EULAPreference.setOnPreferenceClickListener(this); }
From source file:co.edu.uniajc.vtf.content.SwipeContentActivity.java
@Override protected void onPause() { ComponentName loComponent = new ComponentName(this, NetworkStatusReceiver.class); this.getPackageManager().setComponentEnabledSetting(loComponent, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); super.onPause(); }
From source file:com.heightechllc.breakify.MainActivity.java
@Override protected void onDestroy() { super.onDestroy(); // Enable or disable the RescheduleReceiver, which restores AlarmManagers when the system // boots or the time changes. We only want it enabled if an alarm is scheduled, or if // Scheduled Start is enabled. int enabledState; if (timerState == TIMER_STATE_RUNNING || ScheduledStart.isEnabled(this)) enabledState = PackageManager.COMPONENT_ENABLED_STATE_ENABLED; else/*from w ww . java 2 s. co m*/ enabledState = PackageManager.COMPONENT_ENABLED_STATE_DISABLED; ComponentName receiver = new ComponentName(this, RescheduleReceiver.class); getPackageManager().setComponentEnabledSetting(receiver, enabledState, PackageManager.DONT_KILL_APP); // Send any unsent analytics events if (mixpanel != null) mixpanel.flush(); }
From source file:de.stadtrallye.rallyesoft.services.UploadService.java
private void setEnableNetworkStateListener(boolean enable) { ComponentName receiver = new ComponentName(getApplicationContext(), NetworkStatusReceiver.class); PackageManager pm = getApplicationContext().getPackageManager(); pm.setComponentEnabledSetting(receiver, enable ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED : PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); }
From source file:com.tasomaniac.muzei.earthview.ui.SettingsFragment.java
@Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String s) { new BackupManager(getActivity()).dataChanged(); // Potentially enable/disable the launcher activity if the settings button // preference has changed. final String launcherIntentKey = getString(R.string.pref_key_launcher_intent); if (isAdded() && launcherIntentKey.equals(s)) { final boolean hideLauncher = sharedPreferences.getBoolean(launcherIntentKey, false); getActivity().getPackageManager().setComponentEnabledSetting( new ComponentName(getActivity().getPackageName(), LAUNCHER_ACTIVITY_NAME), hideLauncher ? PackageManager.COMPONENT_ENABLED_STATE_DISABLED : PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP); }//from w ww. ja va 2 s .c om }