Created
August 6, 2018 17:15
-
-
Save Sren-Hmkn/5cd071994794b9371fa7cc5d74ca06b0 to your computer and use it in GitHub Desktop.
Ask for external storage read and write permissions
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
<!-- | |
<uses-permission android:name="android.permission.CAMERA" /> | |
Add the following two lines below the line above --> | |
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> | |
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> | |
<!-- ... --> |
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
//... | |
//public class MainActivity extends AppCompatActivity { | |
static final Integer WRITE_EXST = 0x3; | |
static final Integer READ_EXST = 0x4; | |
// static final Integer CAMERA = 0x5; | |
//... | |
//... | |
// replace the whole ask-method with the following code: | |
public boolean ask() { | |
boolean answer = false; | |
if (askForPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE, WRITE_EXST)) { | |
if (askForPermission(Manifest.permission.READ_EXTERNAL_STORAGE, READ_EXST)) { | |
if (askForPermission(Manifest.permission.CAMERA, CAMERA)) { | |
answer = true; | |
} | |
} | |
} else { | |
answer = false; | |
} | |
return answer; | |
} | |
//... | |
//} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment