StartActivity opens gallery apps but not drawing jpg image (Android 4.0)?

I have a very simple android app to open an image in a gallery from a drawable. But when I run it on Galaxy Nexus (4.0.2) using debug mode, it opens the gallery, but not the image. I'm sure I wrote the filename correctly, I have the same copy in drawable, drawable-hdpi, drawable-ldpi, drawable-mdpi and even drawable-xhdpi:


import android.content.Intent;
import android.os.Bundle;

public class SingaporeMapActivity extends Activity {
    /** Called when the activity is first created. */
    public void onCreate(Bundle savedInstanceState) {

        Intent myIntent = new Intent(Intent.ACTION_VIEW);
        myIntent.setData(Uri.parse("android.resource://" + R.drawable.singapore_mrt2012));


And in the magazines, you don't see intent.

Here is the logCat:

03-05 18:16:09.211: I/WindowManager(189): createSurface Window{4204bc78 Starting 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 for activity 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} 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 paused=false}: DRAW NOW PENDING
03-05 18:16:09.859: W/InputManagerService(189): Starting input on non-focused client$Stub$Proxy@418356b0 (uid=10058 pid=15378)
03-05 18:16:09.906: I/ActivityManager(189): Displayed +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


Using an Android emulator I got "unfortunately the camera has stopped"

Thank you for your help.

more magazines ...

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



source to share

1 answer

Uri for your resource is wrong. Since it does not allow anything in your package, the gallery does not open anything as expected.



All Articles