Reputation: 453
When I'm running my application for the first time, I need to set the storage off and then again on in the settings on my android phone, otherwise I cant click on my listview with the pictures that I saved. I have tried adding the permission for the camera but it is instantly crashing then.
I dont know why this is happening but this is my android manifest:
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET" />
Runtime permission
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M){
// start runtime permission
int ALL_PERMISSIONS = 101;
String hasLocation = (Manifest.permission.ACCESS_FINE_LOCATION);
String hasStorage = (Manifest.permission.READ_EXTERNAL_STORAGE);
final String[] permissions = new String[]{hasLocation, hasStorage};
ActivityCompat.requestPermissions(this, permissions, ALL_PERMISSIONS);
Upvotes: 0
Views: 47
Reputation: 75629
Starting from Android 6.0 Manifest permission system is no longer used for apps built with targetSdk 23 or higher, therefore you need to implement runtime permissions.
If the device is running Android 6.0 (API level 23) or higher, and the app's targetSdkVersion is 23 or higher, the user isn't notified of any app permissions at install time. Your app must ask the user to grant the dangerous permissions at runtime.
https://developer.android.com/guide/topics/permissions/overview
Upvotes: 1