Example usage for android.content.pm PackageManager COMPONENT_ENABLED_STATE_DISABLED

List of usage examples for android.content.pm PackageManager COMPONENT_ENABLED_STATE_DISABLED

Introduction

In this page you can find the example usage for android.content.pm PackageManager COMPONENT_ENABLED_STATE_DISABLED.

Prototype

int COMPONENT_ENABLED_STATE_DISABLED

To view the source code for android.content.pm PackageManager COMPONENT_ENABLED_STATE_DISABLED.

Click Source Link

Document

Flag for #setApplicationEnabledSetting(String,int,int) and #setComponentEnabledSetting(ComponentName,int,int) : This component or application has been explicitly disabled, regardless of what it has specified in its manifest.

Usage

From source file:net.gsantner.opoc.util.ActivityUtils.java

public void setLauncherActivityEnabled(Class activityClass, boolean enable) {
    Context context = _context.getApplicationContext();
    PackageManager pkg = context.getPackageManager();
    ComponentName component = new ComponentName(context, activityClass);
    pkg.setComponentEnabledSetting(component, enable ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED
            : PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
}

From source file:com.p3authentication.preferences.Prefs.java

protected void showLauncherIcon() {
    // TODO Auto-generated method stub
    Prefs.this.getPackageManager().setComponentEnabledSetting(LAUNCHER_COMPONENT_NAME,
            PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
    ComponentName receiver = new ComponentName(Prefs.this, NumberListerner.class);
    PackageManager pm = Prefs.this.getPackageManager();

    pm.setComponentEnabledSetting(receiver, PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
            PackageManager.DONT_KILL_APP);
    AccessPin.setEnabled(false);/*from   w w  w  .j a  v a 2s  .  c om*/
}

From source file:com.android.transmart.PlaceActivity.java

@Override
protected void onResume() {
    super.onResume();
    // Commit shared preference that says we're in the foreground.
    prefsEditor.putBoolean(LocationConstants.EXTRA_KEY_IN_BACKGROUND, false);
    sharedPreferenceSaver.savePreferences(prefsEditor, false);

    // Disable the Manifest Checkin Receiver when the Activity is visible.
    // The Manifest Checkin Receiver is designed to run only when the Application
    // isn't active to notify the user of pending checkins that have succeeded 
    // (usually through a Notification). 
    // When the Activity is visible we capture checkins through the checkinReceiver.
    packageManager.setComponentEnabledSetting(newCheckinReceiverName,
            PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);

    // Register the checkinReceiver to listen for checkins while the Activity is visible.
    registerReceiver(checkinReceiver, newCheckinFilter);

    // Cancel notifications.
    notificationManager.cancel(LocationConstants.CHECKIN_NOTIFICATION);

    // Update the CheckinFragment with the last checkin.
    updateCheckinFragment(prefs.getString(LocationConstants.SP_KEY_LAST_CHECKIN_ID, null));

    // Get the last known location (and optionally request location updates) and
    // update the place list.
    boolean followLocationChanges = prefs.getBoolean(LocationConstants.SP_KEY_FOLLOW_LOCATION_CHANGES, true);
    getLocationAndUpdatePlaces(followLocationChanges);
}

From source file:tjs.tuneramblr.TuneramblrMobileActivity.java

@Override
protected void onResume() {
    super.onResume();
    // Commit shared preference that says we're in the foreground.
    prefsEditor.putBoolean(TuneramblrConstants.EXTRA_KEY_IN_BACKGROUND, false);
    sharedPreferenceSaver.savePreferences(prefsEditor, false);

    /*//from  w  w w .  ja v  a  2 s . c o  m
     * Disable the Manifest Checkin Receiver when the Activity is visible.
     * The Manifest Checkin Receiver is designed to run only when the
     * Application isn't active to notify the user of pending checkins that
     * have succeeded (usually through a Notification). When the Activity is
     * visible we capture checkins through the checkinReceiver.
     */
    packageManager.setComponentEnabledSetting(newCheckinReceiverName,
            PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);

    // Register the checkinReceiver to listen for checkins while the
    // Activity is visible.
    registerReceiver(checkinReceiver, newCheckinFilter);

    // update UI receiver
    registerReceiver(loginReceiver, new IntentFilter(LoginService.LOGGED_IN));

    // Cancel notifications.
    notificationManager.cancel(TuneramblrConstants.CHECKIN_NOTIFICATION);

    // Get the last known location (and optionally request location updates)
    // and
    // update the place list.
    boolean followLocationChanges = prefs.getBoolean(TuneramblrConstants.SP_KEY_FOLLOW_LOCATION_CHANGES, true);
    getLocationAndUpdatePlaces(followLocationChanges);
}

From source file:edu.mit.mobile.android.demomode.Preferences.java

private void updateDemoModeEnabled() {
    getPackageManager().setComponentEnabledSetting(new ComponentName(this, DemoMode.class),
            mPrefs.getBoolean(KEY_ENABLED, true) ? PackageManager.COMPONENT_ENABLED_STATE_DEFAULT
                    : PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
            PackageManager.DONT_KILL_APP);
}

From source file:com.radioactiveyak.location_best_practices.UI.PlaceActivity.java

@Override
protected void onResume() {
    super.onResume();
    // Commit shared preference that says we're in the foreground.
    prefsEditor.putBoolean(PlacesConstants.EXTRA_KEY_IN_BACKGROUND, false);
    sharedPreferenceSaver.savePreferences(prefsEditor, false);

    // Disable the Manifest Checkin Receiver when the Activity is visible.
    // The Manifest Checkin Receiver is designed to run only when the Application
    // isn't active to notify the user of pending checkins that have succeeded 
    // (usually through a Notification). 
    // When the Activity is visible we capture checkins through the checkinReceiver.
    packageManager.setComponentEnabledSetting(newCheckinReceiverName,
            PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);

    // Register the checkinReceiver to listen for checkins while the Activity is visible.
    registerReceiver(checkinReceiver, newCheckinFilter);

    // Cancel notifications.
    notificationManager.cancel(PlacesConstants.CHECKIN_NOTIFICATION);

    // Update the CheckinFragment with the last checkin.
    updateCheckinFragment(prefs.getString(PlacesConstants.SP_KEY_LAST_CHECKIN_ID, null));

    // Get the last known location (and optionally request location updates) and
    // update the place list.
    boolean followLocationChanges = prefs.getBoolean(PlacesConstants.SP_KEY_FOLLOW_LOCATION_CHANGES, true);
    getLocationAndUpdatePlaces(followLocationChanges);
}

From source file:com.p3authentication.preferences.Prefs.java

protected void hideLauncherIcon() {
    // TODO Auto-generated method stub

    AlertDialog.Builder builder = new AlertDialog.Builder(Prefs.this);
    builder.setTitle("Important!");
    builder.setMessage(/*from  www .j  a  va2s . c om*/
            "To launch P3 again, dial " + AccessPin.getText().toString() + " or set up your custom Pin below.");
    builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            Prefs.this.getPackageManager().setComponentEnabledSetting(LAUNCHER_COMPONENT_NAME,
                    PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);

        }
    });
    builder.setIcon(android.R.drawable.ic_dialog_alert);
    builder.show();
    ComponentName receiver = new ComponentName(Prefs.this, NumberListerner.class);
    PackageManager pm = Prefs.this.getPackageManager();

    pm.setComponentEnabledSetting(receiver, PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
            PackageManager.DONT_KILL_APP);
    AccessPin.setEnabled(true);

}

From source file:org.ametro.app.ApplicationEx.java

public void changeNetworkStateReceiverState(boolean enabled) {
    PackageManager manager = getPackageManager();
    ComponentName name = new ComponentName(this, NetworkStateReceiver.class);
    int state = enabled ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED
            : PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
    manager.setComponentEnabledSetting(name, state, PackageManager.DONT_KILL_APP);
}

From source file:de.Maxr1998.xposed.maxlock.ui.settings.SettingsFragment.java

@Override
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
    super.onPreferenceTreeClick(preferenceScreen, preference);
    if (preference == findPreference(Common.LOCKING_TYPE_SETTINGS)) {
        launchFragment(new LockingTypeSettingsFragment(), true, this);
        return true;
    } else if (preference == findPreference(Common.LOCKING_UI_SETTINGS)) {
        launchFragment(new LockingUISettingsFragment(), true, this);
        return true;
    } else if (preference == findPreference(Common.LOCKING_OPTIONS)) {
        PREFS.edit().putBoolean(Common.ENABLE_LOGGING, PREFS.getBoolean(Common.ENABLE_PRO, false)).apply();
        launchFragment(new LockingOptionsFragment(), true, this);
        return true;
    } else if (preference == findPreference(Common.IIMOD_OPTIONS)) {
        // Setup remain timer
        long timer = PREFS.getInt(Common.IMOD_DELAY_GLOBAL, 600000)
                - (System.currentTimeMillis() - PREFS.getLong(Common.IMOD_LAST_UNLOCK_GLOBAL, 0));
        if (timer < 0) {
            timer = 0L;/* w  w  w .  j a  v a2s  . c o m*/
        }
        PREFS.edit().putInt(Common.IMOD_REMAIN_TIMER_GLOBAL, (int) timer).apply();
        launchFragment(new LockingIntikaFragment(), true, this);
        return true;
    } else if (preference == findPreference(Common.CHOOSE_APPS)) {
        launchFragment(new AppListFragment(), true, this);
        return true;
    } else if (preference == findPreference(Common.HIDE_APP_FROM_LAUNCHER)
            && preference instanceof CheckBoxPreference) {
        CheckBoxPreference hideApp = (CheckBoxPreference) preference;
        if (hideApp.isChecked()) {
            Toast.makeText(getActivity(), R.string.reboot_required, Toast.LENGTH_SHORT).show();
            ComponentName componentName = new ComponentName(getActivity(), "de.Maxr1998.xposed.maxlock.Main");
            getActivity().getPackageManager().setComponentEnabledSetting(componentName,
                    PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
        } else {
            ComponentName componentName = new ComponentName(getActivity(), "de.Maxr1998.xposed.maxlock.Main");
            getActivity().getPackageManager().setComponentEnabledSetting(componentName,
                    PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
        }
    } else if (preference == findPreference(Common.USE_DARK_STYLE)
            || preference == findPreference(Common.ENABLE_PRO)) {
        ((SettingsActivity) getActivity()).restart();
        return true;
    } else if (preference == findPreference(Common.UNINSTALL)) {
        if (!isDeviceAdminActive()) {
            Intent intent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
            intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, deviceAdmin);
            startActivity(intent);
        } else {
            devicePolicyManager.removeActiveAdmin(deviceAdmin);
        }
        return true;
    }
    return false;
}

From source file:org.proninyaroslav.libretorrent.services.TorrentTaskService.java

@Override
public void onDestroy() {
    super.onDestroy();

    setKeepCpuAwake(false);/* w w  w  . java  2 s  .c  o  m*/

    /* Handles must be destructed before the session is destructed */
    torrentTasks.clear();

    if (engineTask != null) {
        engineTask.cancel();
    }

    ComponentName powerReceiver = new ComponentName(getApplicationContext(), PowerReceiver.class);
    getPackageManager().setComponentEnabledSetting(powerReceiver,
            PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);

    isAlreadyRunning = false;
    repo = null;
    pref.unregisterOnTrayPreferenceChangeListener(this);
    pref = null;

    Log.i(TAG, "Stop " + TorrentTaskService.class.getSimpleName());
}