Example usage for android.content Intent EXTRA_PACKAGE_NAME

List of usage examples for android.content Intent EXTRA_PACKAGE_NAME

Introduction

In this page you can find the example usage for android.content Intent EXTRA_PACKAGE_NAME.

Prototype

String EXTRA_PACKAGE_NAME

To view the source code for android.content Intent EXTRA_PACKAGE_NAME.

Click Source Link

Document

Intent extra: An app package name.

Usage

From source file:Main.java

public static Intent getAppStoreLink(Context context, String installerPackageName, String packageName) {
    Intent intent = new Intent(Intent.ACTION_SHOW_APP_INFO).setPackage(installerPackageName);
    final Intent result = resolveIntent(context, intent);
    if (result != null) {
        result.putExtra(Intent.EXTRA_PACKAGE_NAME, packageName);
        return result;
    }/*w  w w .  jav  a 2 s.  co m*/
    return null;
}

From source file:com.android.packageinstaller.permission.ui.television.PermissionAppsFragment.java

@Override
public boolean onPreferenceChange(final Preference preference, Object newValue) {
    String pkg = preference.getKey();
    final PermissionApp app = mPermissionApps.getApp(pkg);

    if (app == null) {
        return false;
    }//  w w  w .j  av  a2  s  . c  o m

    if (LocationUtils.isLocationGroupAndProvider(mPermissionApps.getGroupName(), app.getPackageName())) {
        LocationUtils.showLocationDialog(getContext(), app.getLabel());
        return false;
    }

    addToggledGroup(app.getPackageName(), app.getPermissionGroup());

    if (app.isReviewRequired()) {
        Intent intent = new Intent(getActivity(), ReviewPermissionsActivity.class);
        intent.putExtra(Intent.EXTRA_PACKAGE_NAME, app.getPackageName());
        startActivity(intent);
        return false;
    }

    if (newValue == Boolean.TRUE) {
        app.grantRuntimePermissions();
    } else {
        final boolean grantedByDefault = app.hasGrantedByDefaultPermissions();
        if (grantedByDefault || (!app.hasRuntimePermissions() && !mHasConfirmedRevoke)) {
            new AlertDialog.Builder(getContext())
                    .setMessage(grantedByDefault ? R.string.system_warning : R.string.old_sdk_deny_warning)
                    .setNegativeButton(R.string.cancel, null)
                    .setPositiveButton(R.string.grant_dialog_button_deny_anyway, new OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            ((SwitchPreference) preference).setChecked(false);
                            app.revokeRuntimePermissions();
                            if (!grantedByDefault) {
                                mHasConfirmedRevoke = true;
                            }
                        }
                    }).show();
            return false;
        } else {
            app.revokeRuntimePermissions();
        }
    }
    return true;
}