Skip to content

Instantly share code, notes, and snippets.

@martarodriguezm
Created October 16, 2015 06:43
Show Gist options
  • Save martarodriguezm/76eb0e39735bdd9230a6 to your computer and use it in GitHub Desktop.
Save martarodriguezm/76eb0e39735bdd9230a6 to your computer and use it in GitHub Desktop.
Code snippet to asko for system settings permission
new AlertDialog.Builder(this)
.setMessage(R.string.write_settings_title)
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Intent intent = new Intent(android.provider.Settings.ACTION_MANAGE_WRITE_SETTINGS);
intent.setData(Uri.parse("package:" + getPackageName()));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
try {
startActivity(intent);
} catch (Exception e) {
Log.e("Activity", "error starting permission intent", e);
}
}
})
.show();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment