Example usage for android.provider Settings ACTION_APPLICATION_DETAILS_SETTINGS

List of usage examples for android.provider Settings ACTION_APPLICATION_DETAILS_SETTINGS

Introduction

In this page you can find the example usage for android.provider Settings ACTION_APPLICATION_DETAILS_SETTINGS.

Prototype

String ACTION_APPLICATION_DETAILS_SETTINGS

To view the source code for android.provider Settings ACTION_APPLICATION_DETAILS_SETTINGS.

Click Source Link

Document

Activity Action: Show screen of details about a particular application.

Usage

From source file:com.google.android.gms.location.sample.locationupdatesforegroundservice.MainActivity.java

/**
 * Callback received when a permissions request has been completed.
 *///w  w  w . ja  v  a2  s.co  m
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
        @NonNull int[] grantResults) {
    Log.i(TAG, "onRequestPermissionResult");
    if (requestCode == REQUEST_PERMISSIONS_REQUEST_CODE) {
        if (grantResults.length <= 0) {
            // If user interaction was interrupted, the permission request is cancelled and you
            // receive empty arrays.
            Log.i(TAG, "User interaction was cancelled.");
        } else if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
            // Permission was granted.
            mService.requestLocationUpdates();
        } else {
            // Permission denied.
            setButtonsState(false);
            Snackbar.make(findViewById(R.id.activity_main), R.string.permission_denied_explanation,
                    Snackbar.LENGTH_INDEFINITE).setAction(R.string.settings, new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            // Build intent that displays the App settings screen.
                            Intent intent = new Intent();
                            intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
                            Uri uri = Uri.fromParts("package", BuildConfig.APPLICATION_ID, null);
                            intent.setData(uri);
                            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                            startActivity(intent);
                        }
                    }).show();
        }
    }
}

From source file:com.mercandalli.android.apps.files.user.LoginRegisterActivity.java

private void requestAccountPermissionInSettings() {
    Snackbar.make(findViewById(R.id.activity_register_login_signin),
            "FileSpace needs the Contacts permission for using Google.", Snackbar.LENGTH_LONG)
            .setAction(android.R.string.ok, new View.OnClickListener() {
                @Override/*from w ww  .  ja v  a2  s  .com*/
                public void onClick(View view) {
                    final Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
                    intent.setData(Uri.parse("package:" + getPackageName()));
                    startActivity(intent);
                }
            }).show();
}

From source file:com.example.captain_miao.grantap.ShadowPermissionActivity.java

public void showPermissionDenyDialog(final ArrayList<String> deniedPermissions) {

    if (TextUtils.isEmpty(denyMessage)) {
        // denyMessage
        permissionDenied(deniedPermissions);
        return;//from   w  w w .j  a v a2  s .co m
    }

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setMessage(denyMessage).setCancelable(false).setNegativeButton(deniedCloseButtonText,
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    permissionDenied(deniedPermissions);
                }
            });

    if (hasSettingButton) {

        builder.setPositiveButton(settingButtonText, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {

                try {
                    Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
                            .setData(Uri.parse("package:" + packageName));
                    startActivityForResult(intent, REQ_CODE_REQUEST_SETTING);
                } catch (ActivityNotFoundException e) {
                    e.printStackTrace();
                    Intent intent = new Intent(Settings.ACTION_MANAGE_APPLICATIONS_SETTINGS);
                    startActivityForResult(intent, REQ_CODE_REQUEST_SETTING);
                }

            }
        });

    }
    builder.show();
}

From source file:com.google.android.gms.nearby.messages.samples.hellobeacons.MainActivity.java

/**
 * Displays {@link Snackbar} instructing user to visit Settings to grant permissions required by
 * this application./*from  w  w  w.j  av a 2s.c  o  m*/
 */
private void showLinkToSettingsSnackbar() {
    if (mContainer == null) {
        return;
    }
    Snackbar.make(mContainer, R.string.permission_denied_explanation, Snackbar.LENGTH_INDEFINITE)
            .setAction(R.string.settings, new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    // Build intent that displays the App settings screen.
                    Intent intent = new Intent();
                    intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
                    Uri uri = Uri.fromParts("package", BuildConfig.APPLICATION_ID, null);
                    intent.setData(uri);
                    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    startActivity(intent);
                }
            }).show();
}

From source file:com.are.photophone.utils.permissionutils.EasyPermissions.java

/**
 * If user denied permissions with the flag NEVER ASK AGAIN, open a dialog explaining the
 * permissions rationale again and directing the user to the app settings. After the user
 * returned to the app, {@link Activity#onActivityResult(int, int, Intent)} or
 * {@link Fragment#onActivityResult(int, int, Intent)} or
 * {@link android.app.Fragment#onActivityResult(int, int, Intent)} will be called with
 * {@value #SETTINGS_REQ_CODE} as requestCode
 * <p>// w w  w . j  a  v  a2s.  c  om
 * NOTE: use of this method is optional, should be called from
 * {@link PermissionCallbacks#onPermissionsDenied(int, List)}
 *
 * @param object                        the calling Activity or Fragment.
 * @param deniedPerms                   the set of denied permissions.
 * @param negativeButtonOnClickListener negative button on click listener. If the
 *                                      user click the negative button, then this listener will
 *                                      be called. Pass null if you don't want to handle it.
 * @return {@code true} if user denied at least one permission with the flag NEVER ASK AGAIN.
 */
public static boolean checkDeniedPermissionsNeverAskAgain(final Object object, String rationale,
        @StringRes int positiveButton, @StringRes int negativeButton,
        @Nullable DialogInterface.OnClickListener negativeButtonOnClickListener, List<String> deniedPerms) {
    boolean shouldShowRationale;
    for (String perm : deniedPerms) {
        shouldShowRationale = shouldShowRequestPermissionRationale(object, perm);
        if (!shouldShowRationale) {
            final Activity activity = getActivity(object);
            if (null == activity) {
                return true;
            }

            AlertDialog dialog = new AlertDialog.Builder(activity).setIcon(R.drawable.ic_alert)
                    .setMessage(rationale)
                    .setPositiveButton(positiveButton, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
                            Uri uri = Uri.fromParts("package", activity.getPackageName(), null);
                            intent.setData(uri);
                            startAppSettingsScreen(object, intent);
                        }
                    }).setNegativeButton(negativeButton, negativeButtonOnClickListener).create();
            dialog.show();

            return true;
        }
    }

    return false;
}

From source file:moe.johnny.tombstone.ui.PreventFragment.java

private boolean startActivity(int id, String packageName) {
    String action;/*from w  w  w.j a  va  2 s  . co m*/
    if (id == R.string.app_info) {
        action = Settings.ACTION_APPLICATION_DETAILS_SETTINGS;
    } else if (id == R.string.uninstall) {
        action = Intent.ACTION_DELETE;
    } else {
        return false;
    }
    mActivity.startActivity(new Intent(action, Uri.fromParts("package", packageName, null)));
    return true;
}

From source file:com.scrachx.foodfacts.checker.ui.product.ProductActivity.java

@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[],
        @NonNull int[] grantResults) {
    switch (requestCode) {
    case PermissionUtils.MY_PERMISSIONS_REQUEST_CAMERA:
    case PermissionUtils.MY_PERMISSIONS_REQUEST_STORAGE: {
        if (grantResults.length <= 0 || grantResults[0] != PERMISSION_GRANTED) {
            new MaterialDialog.Builder(this).title(R.string.permission_title)
                    .content(R.string.permission_denied).negativeText(R.string.txt_no)
                    .positiveText(R.string.txt_yes).onPositive((dialog, which) -> {
                        Intent intent = new Intent();
                        intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
                        Uri uri = Uri.fromParts("package", getPackageName(), null);
                        intent.setData(uri);
                        startActivity(intent);
                    }).show();// ww w  .  jav a  2 s  . co m
        }
    }
    }
}

From source file:com.google.transporttracker.TrackerActivity.java

private void reportPermissionsError() {
    if (mSwitch != null) {
        mSwitch.setChecked(false);/*from  www .  j  a  va  2 s .co m*/
    }
    Snackbar snackbar = Snackbar.make(findViewById(R.id.rootView),
            getString(R.string.location_permission_required), Snackbar.LENGTH_INDEFINITE)
            .setAction(R.string.enable, new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Intent intent = new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
                    intent.setData(Uri.parse("package:" + getPackageName()));
                    startActivity(intent);
                }
            });

    // Changing message text color
    snackbar.setActionTextColor(Color.RED);

    // Changing action button text color
    View sbView = snackbar.getView();
    TextView textView = (TextView) sbView.findViewById(android.support.design.R.id.snackbar_text);
    textView.setTextColor(Color.YELLOW);
    snackbar.show();
}

From source file:cordova.plugins.Diagnostic.java

public void switchToAppSettings() {
    Log.d(TAG, "Switch to App Settings");
    Intent appIntent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
    Uri uri = Uri.fromParts("package", cordova.getActivity().getPackageName(), null);
    appIntent.setData(uri);/*ww  w .j a va 2s. co  m*/
    cordova.getActivity().startActivity(appIntent);
}

From source file:com.google.android.gms.location.sample.backgroundlocationupdates.MainActivity.java

/**
 * Callback received when a permissions request has been completed.
 *//*from   w  ww .  j ava 2  s  .  c o  m*/
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
        @NonNull int[] grantResults) {
    Log.i(TAG, "onRequestPermissionResult");
    if (requestCode == REQUEST_PERMISSIONS_REQUEST_CODE) {
        if (grantResults.length <= 0) {
            // If user interaction was interrupted, the permission request is cancelled and you
            // receive empty arrays.
            Log.i(TAG, "User interaction was cancelled.");
        } else if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
            // Permission was granted. Kick off the process of building and connecting
            // GoogleApiClient.
            buildGoogleApiClient();
        } else {
            // Permission denied.

            // Notify the user via a SnackBar that they have rejected a core permission for the
            // app, which makes the Activity useless. In a real app, core permissions would
            // typically be best requested during a welcome-screen flow.

            // Additionally, it is important to remember that a permission might have been
            // rejected without asking the user for permission (device policy or "Never ask
            // again" prompts). Therefore, a user interface affordance is typically implemented
            // when permissions are denied. Otherwise, your app could appear unresponsive to
            // touches or interactions which have required permissions.
            Snackbar.make(findViewById(R.id.activity_main), R.string.permission_denied_explanation,
                    Snackbar.LENGTH_INDEFINITE).setAction(R.string.settings, new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            // Build intent that displays the App settings screen.
                            Intent intent = new Intent();
                            intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
                            Uri uri = Uri.fromParts("package", BuildConfig.APPLICATION_ID, null);
                            intent.setData(uri);
                            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                            startActivity(intent);
                        }
                    }).show();
        }
    }
}