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:

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);
    }
}

      

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 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

      

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 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

      

+3


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.



0


source







All Articles