Created
October 16, 2015 06:43
-
-
Save martarodriguezm/76eb0e39735bdd9230a6 to your computer and use it in GitHub Desktop.
Code snippet to asko for system settings permission
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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