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.trail.octo.UploadDocs.java

public boolean askCameraPermission() {
    check = false;/*from w ww  . j a v a  2  s. c o  m*/
    // Here, thisActivity is the current activity
    if (ContextCompat.checkSelfPermission(UploadDocs.this,
            Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {

        // Should we show an explanation?
        if (ActivityCompat.shouldShowRequestPermissionRationale(UploadDocs.this, Manifest.permission.CAMERA)) {
            Log.e("Permission", "Explain here");
            Toast.makeText(getApplicationContext(), "OCTO requires this Permission to upload Images!",
                    Toast.LENGTH_LONG).show();
            final Intent i = new Intent();
            i.setAction(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
            i.addCategory(Intent.CATEGORY_DEFAULT);
            i.setData(Uri.parse("package:" + UploadDocs.this.getPackageName()));
            i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            i.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
            i.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
            startActivity(i);

            // Show an expanation to the user *asynchronously* -- don't block
            // this thread waiting for the user's response! After the user
            // sees the explanation, try again to request the permission.

        } else {

            // No explanation needed, we can request the permission.
            Log.e("Permission", "Requesting");
            ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.CAMERA },
                    PERMISSION_REQUEST_CAMERA);
            // MY_PERMISSIONS_REQUEST_READ_CONTACTS is an
            // app-defined int constant. The callback method gets the
            // result of the request.
        }
    } else {
        return true;
    }
    return check;
}

From source file:org.totschnig.myexpenses.activity.ProtectedFragmentActivity.java

public void requestCalendarPermission() {
    if (calendarPermissionPermanentlyDeclined()) {
        //noinspection InlinedApi
        Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
        Uri uri = Uri.fromParts("package", getPackageName(), null);
        intent.setData(uri);/*w  w w.  j  a v  a2s.  c om*/
        startActivity(intent);
    } else {
        ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.WRITE_CALENDAR },
                ProtectionDelegate.PERMISSIONS_REQUEST_WRITE_CALENDAR);
    }
}

From source file:com.base.utils.permission.EasyPermissions.java

@TargetApi(11)
public static void startAppSettings(Object object) {
    final Activity activity = getActivity(object);
    if (null == activity) {
        return;//from  w w w.ja  va2 s .  com
    }
    Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
    Uri uri = Uri.fromParts("package", activity.getPackageName(), null);
    intent.setData(uri);
    startAppSettingsScreen(object, intent);
}

From source file:com.wspa.dm.eopiekun.GetLocationAdress.java

/**
 * Callback received when a permissions request has been completed.
 *//*from ww w  .j  a  v  a 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 granted.
            getAddress();
        } 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.
            showSnackbar(R.string.permission_denied_explanation, 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);
                }
            });
        }
    }
}

From source file:org.iota.wallet.ui.activity.MainActivity.java

@SuppressWarnings("StatementWithEmptyBody")
@Override//from  www  . j  av a2  s . co  m
public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[],
        @NonNull int[] grantResults) {
    switch (requestCode) {
    case Constants.REQUEST_CAMERA_PERMISSION:
        if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {

            // permission was granted!

        } else {

            // permission denied!

            if (!ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.CAMERA)) {
                Snackbar.make(findViewById(R.id.drawer_layout), R.string.messages_permission_camera,
                        Snackbar.LENGTH_LONG).setAction(R.string.buttons_ok, view -> {
                            Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
                                    Uri.parse("package:" + getPackageName()));
                            intent.addCategory(Intent.CATEGORY_DEFAULT);
                            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                            startActivityForResult(intent, Constants.REQUEST_CAMERA_PERMISSION);
                        }).show();
            }
        }
    }
}

From source file:com.garlicg.screenrecord4cm.SettingsActivity.java

/**
 * ????????/*from ww w .  j  ava2s.  c  om*/
 */
private void showPermissionRationale(String reason) {
    AlertDialog.Builder ab = new AlertDialog.Builder(this);
    ab.setMessage(reason);
    ab.setPositiveButton(R.string.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);
            startActivity(intent);
        }
    });
    ab.create().show();
}

From source file:com.trail.octo.UploadDocs.java

public boolean askGalleryPermission() {
    check = false;//from   w w  w .ja v  a 2 s. co m
    // Here, thisActivity is the current activity
    if (ContextCompat.checkSelfPermission(UploadDocs.this,
            Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {

        // Should we show an explanation?
        if (ActivityCompat.shouldShowRequestPermissionRationale(UploadDocs.this,
                Manifest.permission.READ_EXTERNAL_STORAGE)) {
            Log.e("Permission", "Explain here");
            Toast.makeText(getApplicationContext(), "OCTO requires this Permission to upload Images!",
                    Toast.LENGTH_LONG).show();
            final Intent i = new Intent();
            i.setAction(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
            i.addCategory(Intent.CATEGORY_DEFAULT);
            i.setData(Uri.parse("package:" + UploadDocs.this.getPackageName()));
            i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            i.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
            i.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
            startActivity(i);
            // Show an expanation to the user *asynchronously* -- don't block
            // this thread waiting for the user's response! After the user
            // sees the explanation, try again to request the permission.
        } else {

            // No explanation needed, we can request the permission.
            Log.e("Permission", "Requesting");
            ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.READ_EXTERNAL_STORAGE },
                    PERMISSION_REQUEST_READ_EXTERAL_STORAGE);

            // MY_PERMISSIONS_REQUEST_READ_CONTACTS is an
            // app-defined int constant. The callback method gets the
            // result of the request.
        }
    } else {
        return true;
    }
    return check;
}

From source file:com.google.android.apps.muzei.settings.SettingsChooseSourceFragment.java

private void redrawSources() {
    if (mSourceContainerView == null || !isAdded()) {
        return;//w  w  w .  ja va 2s  . c om
    }

    mSourceContainerView.removeAllViews();
    for (final Source source : mSources) {
        source.rootView = LayoutInflater.from(getActivity()).inflate(R.layout.settings_choose_source_item,
                mSourceContainerView, false);

        source.selectSourceButton = source.rootView.findViewById(R.id.source_image);
        source.selectSourceButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (source.componentName.equals(mSelectedSource)) {
                    ((Callbacks) getActivity()).onRequestCloseActivity();
                } else if (source.setupActivity != null) {
                    mCurrentInitialSetupSource = source.componentName;
                    launchSourceSetup(source);
                } else {
                    mSourceManager.selectSource(source.componentName);
                }
            }
        });

        source.selectSourceButton.setOnLongClickListener(new View.OnLongClickListener() {

            @Override
            public boolean onLongClick(View v) {
                final String pkg = source.componentName.getPackageName();
                if (TextUtils.equals(pkg, getActivity().getPackageName())) {
                    // Don't open Muzei's app info
                    return false;
                }
                // Otherwise open third party extensions
                try {
                    startActivity(new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
                            Uri.fromParts("package", pkg, null)));
                } catch (final ActivityNotFoundException e) {
                    return false;
                }
                return true;
            }
        });

        source.rootView.setAlpha(ALPHA_UNSELECTED);

        source.icon.setColorFilter(source.color, PorterDuff.Mode.SRC_ATOP);
        source.selectSourceButton.setBackground(source.icon);

        TextView titleView = (TextView) source.rootView.findViewById(R.id.source_title);
        titleView.setText(source.label);
        titleView.setTextColor(source.color);

        updateSourceStatusUi(source);

        source.settingsButton = source.rootView.findViewById(R.id.source_settings_button);
        CheatSheet.setup(source.settingsButton);
        source.settingsButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                launchSourceSettings(source);
            }
        });

        animateSettingsButton(source.settingsButton, false, false);

        mSourceContainerView.addView(source.rootView);
    }

    updateSelectedItem(false);
}

From source file:com.peptrack.gps.locationupdatesforegroundservice.MainActivity.java

/**
 * Callback received when a permissions request has been completed.
 *//*from  w w w  .  j  av  a  2s.  c om*/
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
        @NonNull int[] grantResults) {
    Log.i(TAG, "onRequestPermissionResult");
    if (requestCode == REQUEST_PERMISSIONS_LOCATION_REQUEST_CODE
            || requestCode == REQUEST_PERMISSIONS_INTERNET_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.tasomaniac.openwith.resolver.ResolverActivity.java

@SuppressWarnings("deprecation")
void showAppDetails(ResolveInfo ri) {
    Intent in = new Intent().setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
            .setData(Uri.fromParts("package", ri.activityInfo.packageName, null))
            .addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
    startActivity(in);//from w  ww . j a  v a 2s .  com
}