Permission Denial: … requires android.permission.WRITE_EXTERNAL_STORAGE

帅比萌擦擦* 提交于 2019-12-13 12:03:47

问题


So the latest wall I've hit is in trying to write to the sdcard with my program. I'm getting:

[2011-05-28 10:00:16 - LatinDictionary] ActivityManager: java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.joelman.latindictionary/.LatinDictionary } from null (pid=-1, uid=-1) requires android.permission.WRITE_EXTERNAL_STORAGE

As you can see from my manifest below, I've added the permission (I also tried adding it to each of the activities, to no avail). What am I missing?

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.joelman.latindictionary"
      android:versionCode="1"
      android:versionName="1.0">
     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
     <application android:icon="@drawable/icon" android:label="@string/app_name" android:permission="android.permission.WRITE_EXTERNAL_STORAGE">
     <activity android:name=".LatinDictionary">
     <intent-filter>
     <action android:name="android.intent.action.MAIN"></action>
<category android:name="android.intent.category.LAUNCHER"></category>
</intent-filter>
<intent-filter><action android:name="android.intent.action.SEARCH"></action>
</intent-filter>
</activity>

<provider android:name="DictionaryProvider" android:authorities="com.joelman.latindictionary.DictionaryProvider"></provider>
</application>

</manifest> 

TIA, Joel


回答1:


It should be like this:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.joelman.latindictionary"
      android:versionCode="1"
      android:versionName="1.0">
     <application android:icon="@drawable/icon" android:label="@string/app_name" android:permission="android.permission.WRITE_EXTERNAL_STORAGE">
     <activity android:name=".LatinDictionary">
     <intent-filter>
     <action android:name="android.intent.action.MAIN"></action>
<category android:name="android.intent.category.LAUNCHER"></category>
</intent-filter>
<intent-filter><action android:name="android.intent.action.SEARCH"></action>
</intent-filter>
</activity>

<provider android:name="DictionaryProvider" android:authorities="com.joelman.latindictionary.DictionaryProvider"></provider>
</application>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
</manifest> 



回答2:


Put the permission line outside the application tag, but within the manifest one



来源:https://stackoverflow.com/questions/6162081/permission-denial-requires-android-permission-write-external-storage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!