如何使用adb shell显示本地图像 [英] How to use adb shell to display a local image

查看:2061
本文介绍了如何使用adb shell显示本地图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 adb shell 告诉我的设备在其SD卡上显示图像。我以为这个命令会起作用:

I want to use adb shell to tell my device to display an image on its SD card. I thought this command would work:

adb shell am start -a android.intent.action.MAIN -n com.android.browser/.BrowserActivity -d file:///storage/sdcard0/Android/data/<mypackage>/files/myfile.jpg

不幸的是,我收到此错误:

Unfortunately I get this error:


开始:Intent {act = android.intent.action.MAIN
cmp = com.android.browser / .BrowserActivity}

错误类型3

错误:活动类
{com.android.browser / com.android。 browser.BrowserActivity}不存在

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 参数。

I also tried doing a VIEW action, and trying with only the -n or the -d parameters.

adb shell am start -a android.intent.action.VIEW -d file:///storage/sdcard0/Android/data/<mypackage>/files/myfile.jpg

仅使用 -d 参数导致此错误(我尝试了两种h,且路径上没有 file://前缀):

Using only the -d parameter results in this error (I tried both with and without the "file://" prefix on the path):


开始:Intent {act = android.intent.action。查看
dat = / storage / sdcard0 / Android / data // files / myfile.jpg
}

错误:活动未开始,无法解决意图{
行动= android.intent.action.VIEW
dat = / storage / sdcard0 / Android / data // files / myfile.jpg
flg = 0x10000000}

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

我正在测试植根的Galaxy运行4.1.1的Nexus。

I'm testing with a rooted Galaxy Nexus running 4.1.1.

更新:我尝试了dtmilano的建议,但裁剪工具弹出了无法加载图像对话框。 logcat的堆栈跟踪为:

Update: I tried dtmilano's suggestion but the Crop tool gives a "Couldn't load the image" popup. The stack trace from logcat is:

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卡,并且可能图像已被视为应用程序数据,那么其他应用程序将无法访问它?

I'm wondering if this is an internal SD card, and maybe the images are being treated as application data, so other apps can't access it?

推荐答案

这应该可以工作,但是取决于您安装的应用程序:

This should work, however it's dependant on the apps you have installed:

$ adb shell am start -t image/* -d file:///mnt/sdcard/myfile.jpg

有趣的是,它没有如果您在使用...完成操作... 中选择图库,则可以工作,但是如果您选择裁剪图片,则可以工作。
还可以与 Astro Image Viewer 使用。

Interestingly, it doesn't work if you select Gallery in Complete action using..., but works if you select Crop picture. Also works with Astro Image Viewer.

这篇关于如何使用adb shell显示本地图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆