Reputation: 43
After fighting a couple of hours to read something from the sdcard using ADT v22.3.0-887826 I only can think that my manifest is been ignored. Adding 4 lines to the hello world project.
One in the manifest
<permission android:name="android.permission.READ_EXTERNAL_STORAGE"></permission>
Three in the MainActivity.java
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
String permission = "android.permission.READ_EXTERNAL_STORAGE";
int res = getBaseContext().checkCallingOrSelfPermission(permission);
System.out.println("permission:"+(res == PackageManager.PERMISSION_GRANTED));
}
The output is "permission:false"
Upvotes: 2
Views: 1868
Reputation: 1905
You should use
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
instead of
<permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
"permission" tag is used when you want your app to give some permissions to other apps.
"uses-permission" is used when YOU ask for some permission, ex read_external_storage, internet, sensors, etc.
Upvotes: 2
Reputation: 126
Why is android emulator ignoring my manifest permissions?
You don't have your permissions set correctly, should be like this:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
the links below should better help you understand why your permissions should be written like that.
http://developer.android.com/guide/topics/security/permissions.html
http://developer.android.com/guide/topics/manifest/uses-permission-element.html
http://developer.android.com/guide/topics/manifest/manifest-intro.html
Upvotes: 0