繁体   English   中英

startActivity打开图库应用程序但不是可绘制的jpg图像(Android 4.0)?

[英]startActivity open gallery apps but not the drawable jpg image ( Android 4.0 )?

我有一个非常简单的Android应用程序,用于在drawable中打开图库。 但是当我使用调试模式在Galaxy Nexus(4.0.2)上运行它时,它会打开图库而不是图像。 我确定我正确地写了文件名,我在drawable,drawable-hdpi,drawable-ldpi,drawable-mdpi甚至drawable-xhdpi中都有相同的副本:

package kailu.apps.map;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;

public class SingaporeMapActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        Intent myIntent = new Intent(Intent.ACTION_VIEW);
        myIntent.setData(Uri.parse("android.resource://kailu.apps.map/" + R.drawable.singapore_mrt2012));
        myIntent.setType("image/jpeg");
        startActivity(myIntent);
    }
}

在日志中,您无法看到意图。

这是logCat:

03-05 18:16:09.211: I/WindowManager(189): createSurface Window{4204bc78 Starting kailu.apps.map paused=false}: DRAW NOW PENDING
03-05 18:16:09.328: D/dalvikvm(22940): Late-enabling CheckJNI
03-05 18:16:09.336: I/ActivityManager(189): Start proc kailu.apps.map for activity kailu.apps.map/.SingaporeMapActivity: pid=22940 uid=10134 gids={}
03-05 18:16:09.508: D/OpenGLRenderer(15378): Flushing caches (mode 1)
03-05 18:16:09.555: D/OpenGLRenderer(15378): Flushing caches (mode 0)
03-05 18:16:09.578: I/ActivityManager(189): START {act=android.intent.action.VIEW typ=image/jpg cmp=com.rhmsoft.fm/.ImageGallery} from pid 22940
03-05 18:16:09.734: D/dalvikvm(189): GC_EXPLICIT freed 1447K, 20% free 27519K/34119K, paused 8ms+8ms
03-05 18:16:09.758: I/WindowManager(189): createSurface Window{421fce58 com.rhmsoft.fm/com.rhmsoft.fm.ImageGallery paused=false}: DRAW NOW PENDING
03-05 18:16:09.859: W/InputManagerService(189): Starting input on non-focused client com.android.internal.view.IInputMethodClient$Stub$Proxy@418356b0 (uid=10058 pid=15378)
03-05 18:16:09.906: I/ActivityManager(189): Displayed com.rhmsoft.fm/.ImageGallery: +172ms (total +585ms)
03-05 18:16:09.914: V/PhoneStatusBar(264): setLightsOn(true)
03-05 18:16:09.922: I/ggheart(15378): onStop
03-05 18:16:39.727: I/power(189): *** set_screen_state 0
03-05 18:16:39.805: D/SurfaceFlinger(116): About to give-up screen, flinger = 0xf918

使用Android模拟器我得到“不幸,相机已经停止”

谢谢你的帮助。

更多日志......

03-05 18:33:52.375: I/ActivityManager(189):   Force finishing activity ActivityRecord{41844328 kailu.apps.map/.SingaporeMapActivity}
03-05 18:33:55.406: I/ActivityManager(189): START {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=kailu.apps.map/.SingaporeMapActivity} from pid 23478
03-05 18:33:55.539: I/ActivityManager(189): Start proc kailu.apps.map for activity kailu.apps.map/.SingaporeMapActivity: pid=23503 uid=10134 gids={}
03-05 18:34:00.086: I/WindowManager(189): WIN DEATH: Window{427e96b8 kailu.apps.map/kailu.apps.map.SingaporeMapActivity paused=false}
03-05 18:34:31.430: I/DownloadManager(23759): in removeSpuriousFiles, preserving file /mnt/sdcard/Download/singapore-mrt-lrt-map.jpg

您的资源的Uri格式不正确。 由于它在您的包中没有解析为任何内容,因此库将按预期打开。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM