我想使用adb shell
告訴我的設備在其SD卡上顯示圖像。我想這個命令會工作:如何使用adb外殼來顯示本地圖像
adb shell am start -a android.intent.action.MAIN -n com.android.browser/.BrowserActivity -d file:///storage/sdcard0/Android/data/<mypackage>/files/myfile.jpg
不幸的是我得到這個錯誤:
Starting: Intent { act=android.intent.action.MAIN cmp=com.android.browser/.BrowserActivity }
Error type 3
Error: Activity class {com.android.browser/com.android.browser.BrowserActivity} does not exist.
我也試圖做一個VIEW
動作,並且只用-n
或-d
參數嘗試。
adb shell am start -a android.intent.action.VIEW -d file:///storage/sdcard0/Android/data/<mypackage>/files/myfile.jpg
此錯誤只使用-d
參數結果(我試過有和沒有的「文件://」的路徑前綴):
Starting: Intent { act=android.intent.action.VIEW dat=/storage/sdcard0/Android/data//files/myfile.jpg }
Error: Activity not started, unable to resolve Intent { act=android.intent.action.VIEW dat=/storage/sdcard0/Android/data//files/myfile.jpg flg=0x10000000 }
上的文件的權限是:
-rw-rw-r-- root sdcard_rw 198106 2013-01-02 21:29 gUD9w5.jpg
我使用的是運行4.1.1的rooted Galaxy Nexus進行測試。
更新:我試過dtmilano的建議,但裁剪工具給出了「無法加載圖像」彈出窗口。從logcat的堆棧跟蹤爲:
ActivityManager: START {dat=file:///storage/sdcard0/Android/data/<mypackage>/Pictures/myfile.jpg typ=image/*
flg=0x13000000 cmp=com.google.android.gallery3d/com.android.gallery3d.app.CropImage u=0} from pid 301
UriImage: fail to open: file:///storage/sdcard0/Android/data/<mypackage>/Pictures/myfile.jpg
UriImage: java.io.FileNotFoundException: /storage/sdcard0/Android/data/<mypackage>/Pictures/myfile.jpg:
open failed: ENOENT (No such file or directory)
UriImage: at libcore.io.IoBridge.open(IoBridge.java:416)
UriImage: at java.io.FileInputStream.<init>(FileInputStream.java:78)
UriImage: at java.io.FileInputStream.<init>(FileInputStream.java:105)
UriImage: at android.content.ContentResolver.openInputStream(ContentResolver.java:445)
UriImage: at com.android.gallery3d.data.UriImage.openOrDownloadInner(UriImage.java:98)
UriImage: at com.android.gallery3d.data.UriImage.openFileOrDownloadTempFile(UriImage.java:78)
UriImage: at com.android.gallery3d.data.UriImage.prepareInputFile(UriImage.java:164)
UriImage: at com.android.gallery3d.data.UriImage.access$100(UriImage.java:40)
UriImage: at com.android.gallery3d.data.UriImage$RegionDecoderJob.run(UriImage.java:170)
UriImage: at com.android.gallery3d.data.UriImage$RegionDecoderJob.run(UriImage.java:168)
UriImage: at com.android.gallery3d.app.CropImage$LoadDataTask.run(CropImage.java:921)
UriImage: at com.android.gallery3d.app.CropImage$LoadDataTask.run(CropImage.java:913)
UriImage: at com.android.gallery3d.util.ThreadPool$Worker.run(ThreadPool.java:124)
UriImage: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
UriImage: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
UriImage: at java.lang.Thread.run(Thread.java:856)
UriImage: at com.android.gallery3d.util.PriorityThreadFactory$1.run(PriorityThreadFactory.java:43)
UriImage: Caused by: libcore.io.ErrnoException: open failed: ENOENT (No such file or directory)
UriImage: at libcore.io.Posix.open(Native Method)
UriImage: at libcore.io.BlockGuardOs.open(BlockGuardOs.java:110)
UriImage: at libcore.io.IoBridge.open(IoBridge.java:400)
UriImage: ... 16 more
我想如果這是一個內部的SD卡,也許圖像被視爲應用程序數據,以便其他應用不能訪問它?
它應該與'VIEW'一起工作並且不需要'-n com.android.browser/.BrowserActivity'。然後系統應該將意圖解決到正確的課程。 – iagreen
這似乎並沒有爲我工作,我已更新與我看到的錯誤的問題。 –
安裝一個文件管理器應用程序,並嘗試瀏覽和查看它 - 應回答權限問題。也許該文件是可訪問的,但不是通過該路徑名稱*到應用程序用戶的*。 –