1
我實現了一個文件ContentProvider通過HTTP網址訪問WiFi網絡上的文件服務器。Android意圖與圖庫應用程序顯示圖像與文件ContentProvider
我想要做的是啓動一個特定的意圖和uri Android畫廊應用程序來顯示在我的文件服務器上的特定目錄中的圖像文件。
我能夠成功,如果我啓動圖庫應用程序與單一URI通過這個代碼來顯示一個圖像:
Intent lance = new Intent();
lance.setAction(Intent.ACTION_VIEW);
String typedata = "image/*";
lance.setType(typedata);
String phuri = "content://" + URI_AUTORITE
+ "/" + URI_CONTENU_FICHIERS
+ directory + filename;
Uri uri = Uri.parse(phuri);
lance.setDataAndType(uri, "image/*");
startActivity(lance);
但我試圖走一步實現目錄的顯示包含圖像。我試圖用ClipData對象顯示多個圖像,通過這個代碼:
Intent lance = new Intent();
lance.setAction(Intent.ACTION_VIEW);
String typedata = "image/*";
lance.setType(typedata);
String phuri = "content://" + URI_AUTORITE
+ "/" + URI_CONTENU_FICHIERS
+ directory + filename;
Uri uri = Uri.parse(phuri);
ClipData ensemble = ClipData.newRawUri("Photos", uri);
lance.setClipData(ensemble);
startActivity(lance);
它不工作:圖庫應用被啓動,並顯示專輯的列表,並且不叫我的文件的ContentProvider。
Dis我錯過了什麼,或者是Gallery應用開發者的問題嗎?
我的getType方法返回正確的字符串返回圖像的MIME類型,但它是不夠的。 Galery應用程序不會嘗試讀取剪貼數據的內容... – bobygerm
您是否爲內容提供商在清單文件中設置了exported = true? – Greensy