2017-05-25 28 views
0

嘗試在默認庫應用程序中打開圖像。我不解決這個問題,具體操作如下: 我的文件路徑/data/data/{applicationName}/cache/file.jpgIllegalArgumentException:無法找到包含filePath的配置根

意圖:

Intent intent = new Intent(Intent.ACTION_VIEW); 
File file = new File(filePath); 
    intent.setDataAndType(FileProvider.getUriForFile(this, getApplicationContext() 
          .getPackageName() + ".provider", file),"image/*"); 
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); 

清單:

<provider 
    android:name="android.support.v4.content.FileProvider" 
    android:authorities="${applicationId}.provider" 
    android:exported="false" 
    android:grantUriPermissions="true"> 
    <meta-data 
      android:name="android.support.FILE_PROVIDER_PATHS" 
      android:resource="@xml/provider_paths"/> 
</provider> 

provider_paths.xml

<?xml version="1.0" encoding="utf-8"?> 
<paths> 
    <external-path 
     name="external_files" 
     path="." /> 
</paths> 

我已經嘗試在provider_paths中更改路徑和名稱,但沒有運氣。

回答

3

替換:

<external-path 
    name="external_files" 
    path="." /> 

有:

<cache-path name="external_files" /> 

爲您的路徑似乎是在getCacheDir()

相關問題