0

Android中我試圖採取從庫存儲其URI的圖像,然後拉回來,但其顯示拋出:SecurityException加載一些電話說拋出:SecurityException PermissionDenial。請幫幫我。由於圖像不能在Android的

ImageView: Unable to open content: content://com.google.android.apps.photos.contentprovider/-1/1/content%3A%2F%2Fmedia%2Fexternal%2Fimages%2Fmedia%2F70/NO_TRANSFORM/908138224 
                      java.lang.SecurityException: Permission Denial: opening provider com.google.android.apps.photos.contentprovider.MediaContentProvider from ProcessRecord{12795c7f 18283:dccenter.dccenter.com.dccenter/u0a162} (pid=18283, uid=10162) that is not exported from uid 10106 
                       at android.os.Parcel.readException(Parcel.java:1546) 
                       at android.os.Parcel.readException(Parcel.java:1499) 
                       at android.app.ActivityManagerProxy.getContentProvider(ActivityManagerNative.java:3833) 
                       at android.app.ActivityThread.acquireProvider(ActivityThread.java:6084) 
                       at android.app.ContextImpl$ApplicationContentResolver.acquireUnstableProvider(ContextImpl.java:3178) 
                       at android.content.ContentResolver.acquireUnstableProvider(ContentResolver.java:1495) 
                       at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:1115) 
                       at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:970) 
                       at android.content.ContentResolver.openInputStream(ContentResolver.java:695) 
                       at android.widget.ImageView.resolveUri(ImageView.java:784) 
                       at android.widget.ImageView.setImageURI(ImageView.java:440) 
                       at adapter.SlidingImageAdapter.instantiateItem(SlidingImageAdapter.java:118) 

我的Android清單權限

<uses-permission android:name="android.permission.INTERNET" /> 
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> 
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 
<uses-permission android:name="com.google.android.apps.photos.permission.GOOGLE_PHOTOS" /> 
<uses-permission android:name="android.permission.READ_USER_DICTIONARY" /> 
<uses-permission android:name="android.permission.READ_USER_DICTIONARY" /> 
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" /> 
<uses-permission android:name="android.permission.MANAGE_DOCUMENTS"/> 
+1

已聲明的任何許可清單中? –

+0

是的,我給了所有必要的權限。 – Rahul

回答

0

你聲明的權限?

<uses-permission android:name="android.permission.MANAGE_DOCUMENTS"/> 

如果不是,這裏是一個簡單的解決方案:

public static final String KITKAT_VALUE = 1002; 

    Intent intent; 

    if (Build.VERSION.SDK_INT < 19){ 
          intent = new Intent(); 
          intent.setAction(Intent.ACTION_GET_CONTENT); 
          intent.setType("image/*"); 
          startActivityForResult(intent, KITKAT_VALUE); 
         } else { 
          intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); 
          intent.addCategory(Intent.CATEGORY_OPENABLE); 
          intent.setType("image/*"); 
          startActivityForResult(intent, KITKAT_VALUE); 
        } 

@Override 
public void onActivityResult(int requestCode, int resultCode, Intent data) { 
    if (requestCode == KITKAT_VALUE) { 
    if (resultCode == Activity.RESULT_OK) { 
     // do something here 
    } 
    } 
} 
+0

主席先生,我宣佈許可但仍然無法使用。 – Rahul

+0

謝謝你的簡單方式,像魅力一樣工作。 – Rahul