Example usage for android.content.pm PackageManager clearPackagePreferredActivities

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

Introduction

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

Prototype

public abstract void clearPackagePreferredActivities(String packageName);

Source Link

Document

Remove all preferred activity mappings, previously added with #addPreferredActivity , from the system whose activities are implemented in the given package name.

Usage

From source file:Main.java

public static void clearMyDefaultBrowser(Context context) {
    PackageManager pm = context.getPackageManager();
    pm.clearPackagePreferredActivities(context.getPackageName());
}

From source file:Main.java

public static void clearDefaultOpenSetting(Context mContext) {
    PackageManager pm = mContext.getPackageManager();
    pm.clearPackagePreferredActivities(mContext.getPackageName());
}

From source file:uk.co.droidinactu.ebooklauncher.EBookLauncherActivity.java

@Override
public boolean onOptionsItemSelected(final MenuItem item) {
    boolean retvalue = false;
    switch (item.getItemId()) {
    case MENU_PREFERENCES:
        startActivityForResult(new Intent(getApplication(), EditPreferences.class),
                EBookLauncherActivity.ACTIVITY_EDIT_PREFERENCES);
        retvalue = true;/*from w  w  w .  ja va  2  s.c o m*/
        break;

    case MENU_SETTINGS:
        startActivity(new Intent(android.provider.Settings.ACTION_SETTINGS));
        retvalue = true;
        break;

    case MENU_CHECK_NEW_VERSION:
        final Intent i = new Intent(Intent.ACTION_VIEW);
        i.setData(Uri.parse(EBookLauncherActivity.DOWNLOAD_APK_URL));
        startActivity(i);
        break;

    case MENU_CLEAR_DEFAULTS:
        final PackageManager pm = getPackageManager();
        pm.clearPackagePreferredActivities("uk.co.droidinactu.ebooklauncher");
        pm.clearPackagePreferredActivities("com.android.launcher");
        retvalue = true;
        break;

    case MENU_ABOUT:
        this.showAboutWithExtras();
        retvalue = true;
        break;

    default:
        return super.onOptionsItemSelected(item);
    }
    return retvalue;
}