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.abhijitvalluri.android.fitnotifications.setup.AppIntroActivity.java

private void addDNDModeSlide() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        addSlide(new SimpleSlide.Builder().layout(R.layout.fragment_intro).title(R.string.intro_dnd_mode_title)
                .description(R.string.intro_dnd_mode_desc).image(R.drawable.intro_dnd_mode_info)
                .background(R.color.black).backgroundDark(R.color.grey)
                .buttonCtaLabel(R.string.intro_dnd_mode_button)
                .buttonCtaClickListener(new View.OnClickListener() {
                    @Override//from  www.j  a  va 2  s.  c  o m
                    public void onClick(View v) {
                        AlertDialog dialog = new AlertDialog.Builder(AppIntroActivity.this)
                                .setTitle(getString(R.string.intro_dnd_mode_button))
                                .setPositiveButton("Configure", new DialogInterface.OnClickListener() {
                                    @Override
                                    public void onClick(DialogInterface dialog, int which) {
                                        Intent intent = new Intent();
                                        intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
                                        Uri uri = Uri.fromParts("package", Constants.PACKAGE_NAME, null);
                                        intent.setData(uri);
                                        startActivity(intent);
                                    }
                                }).setNegativeButton("CANCEL", null).create();
                        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
                            dialog.setMessage(getString(R.string.intro_dnd_mode_nougat_message));
                        } else {
                            dialog.setMessage(getString(R.string.intro_dnd_mode_message));
                        }
                        dialog.show();
                    }
                }).build());
    }
}

From source file:com.example.weather.SettingsActivity.java

/**
 * ?// w w  w .j  av a 2 s  .c o m
 *
 * @since 2.5.0
 */
private void startAppSettings() {
    Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
    intent.setData(Uri.parse("package:" + getPackageName()));
    startActivity(intent);
}

From source file:com.tfc.webviewer.ui.WebViewerActivity.java

@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
        @NonNull int[] grantResults) {
    if (PermissionUtils.REQUEST_PERMISSION_WRITE_EXTERNAL_STORAGE == requestCode) {
        if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
            mLastDownloadId = FileUtils.downloadFile(this, mDownloadUrl, mDownloadMimetype);
        } else {//from ww w.j a  v  a  2  s  . c  om
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                if (!shouldShowRequestPermissionRationale(permissions[0])) {
                    new AlertDialog.Builder(WebViewerActivity.this)
                            .setTitle(R.string.write_permission_denied_title)
                            .setMessage(R.string.write_permission_denied_message)
                            .setNegativeButton(R.string.dialog_dismiss, null)
                            .setPositiveButton(R.string.dialog_settings, 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", getPackageName(), null);
                                    intent.setData(uri);
                                    startActivityForResult(intent, REQUEST_PERMISSION_SETTING);
                                }
                            }).show();
                }
            }
        }
    }
}

From source file:com.base.utils.permission.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  a2  s.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).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:com.scrachx.foodfacts.checker.ui.main.MainActivity.java

@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[],
        @NonNull int[] grantResults) {
    super.onRequestPermissionsResult(requestCode, permissions, grantResults);
    switch (requestCode) {
    case PermissionUtils.MY_PERMISSIONS_REQUEST_CAMERA: {
        if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
            startActivity(ScannerActivity.getStartIntent(this));
        } else {/*from   w  w  w .  jav a  2s .c  om*/
            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();
        }
        break;
    }
    }
}

From source file:com.tml.sharethem.sender.SHAREthemActivity.java

@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
        @NonNull int[] grantResults) {
    super.onRequestPermissionsResult(requestCode, permissions, grantResults);
    switch (requestCode) {
    case PERMISSIONS_REQUEST_CODE_ACCESS_COARSE_LOCATION:
        if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
            enableAp();// w  ww .j a v  a  2  s  . c o m
        } else {
            if (ActivityCompat.shouldShowRequestPermissionRationale(this,
                    Manifest.permission.ACCESS_COARSE_LOCATION)) {
                showMessageDialogWithListner(getString(R.string.p2p_receiver_gps_permission_warning),
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                checkLocationPermission();
                            }
                        }, true, true);
            } else {
                showMessageDialogWithListner(getString(R.string.p2p_receiver_gps_no_permission_prompt),
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                try {
                                    Intent intent = new Intent();
                                    intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
                                    Uri uri = Uri.fromParts("package", getPackageName(), null);
                                    intent.setData(uri);
                                    startActivity(intent);
                                } catch (ActivityNotFoundException anf) {
                                    Toast.makeText(getApplicationContext(), "Settings activity not found",
                                            Toast.LENGTH_SHORT).show();
                                }
                            }
                        }, true, true);
            }
        }
    }
}

From source file:com.example.android.hdrviewfinder.HdrViewfinderActivity.java

/**
 * Callback received when a permissions request has been completed.
 *///from  w w w.  j a v  a  2 s .  c  om
@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.
            findAndOpenCamera();
        } else {
            // Permission denied.

            // In this Activity we've chosen to notify the user that they
            // have rejected a core permission for the app since it makes the Activity useless.
            // We're communicating this message in a Snackbar since this is a sample app, but
            // 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(rootView, R.string.camera_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.lypeer.fcpermission.FcPermissionsB.java

/**
 * ????????//from  ww  w  . ja va  2s .c om
 */
private 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).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:com.lgallardo.qbittorrentclient.SettingsActivity.java

@Override
public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
    switch (requestCode) {
    case MY_PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE: {
        // If request is cancelled, the result arrays are empty.
        if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {

            // Permissions granted, open file picker
            Intent intent = new Intent(getApplicationContext(), FilePickerActivity.class);
            intent.putExtra(FilePickerActivity.ARG_FILE_FILTER, Pattern.compile(".*\\.bks"));
            startActivityForResult(intent, 1);

        } else {/*from   w  ww .j av a2s.c om*/

            // Permission denied

            // Should we show an explanation?
            if (!ActivityCompat.shouldShowRequestPermissionRationale(this,
                    Manifest.permission.WRITE_EXTERNAL_STORAGE)) {

                genericOkCancelDialog(R.string.error_grant_permission2, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {

                        Intent appIntent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
                        appIntent.setData(Uri.parse("package:" + MainActivity.packageName));
                        startActivityForResult(appIntent, 0);
                    }
                });
            }
            return;
        }
    }
    }
}

From source file:com.minio.io.alice.MainActivity.java

@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[],
        @NonNull int[] grantResults) {
    // Make sure it's our original REQUEST_VIDEO_PERMISSIONS request
    if (requestCode == REQUEST_VIDEO_PERMISSIONS) {
        ArrayList<String> permissionsNeededYet = getPendingPermissions(grantResults, permissions);
        if (permissionsNeededYet.size() == 0) {
            //all permissions granted - allow camera access
            cameraManager.createCameraSource(mCameraId);
            return;

        } else {/*w w w  .  j a v  a 2 s  .c om*/
            // showRationale = false if user clicks Never Ask Again, otherwise true
            boolean showRationale = shouldShowRequestPermissionRationale(
                    permissionsNeededYet.toArray(new String[0]));

            if (!showRationale) {
                Toast.makeText(this,
                        "Video permission denied.Enable camera and location preferences on the App settings",
                        Toast.LENGTH_SHORT).show();
                finish();
            } else {
                Toast.makeText(this,
                        "Alice needs camera,microphone and location enabled to start tracking.Alice will now exit.",
                        Toast.LENGTH_SHORT).show();
                startActivity(new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
                        Uri.parse("package:" + BuildConfig.APPLICATION_ID)));

                finish();
            }
        }
    } else {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
    }
}