权限拒绝:...需要android.permission.WRITE_EXTERNAL_STORAGE

时间:2011-05-28 14:01:51

标签: android permissions

所以我遇到的最新版墙是试图用我的程序写入SD卡。我得到了:

[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

从下面的清单中可以看出,我已经添加了权限(我也尝试将其添加到每个活动中,但无济于事)。我错过了什么?

<?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, 乔尔

2 个答案:

答案 0 :(得分:16)

应该是这样的:

<?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> 

答案 1 :(得分:6)

将权限行放在应用程序标记之外,但在清单中