java - Open Gallery App in Android -
i trying open inbuilt gallery app pressing button in app.
i trying out on android 2.3 , above phones. phones/tablet have
samsung s (android 2.3.5) lg phone (android 2.3.3) nexus 1 (android 2.3.6) android tablet (android 4.0.3) galaxy nexus (android 4.3)
i tried following:
intent intent = new intent(intent.action_view, null); intent.settype("image/*"); startactivity(intent);
above code works fine on android tablet (4.0.3) , nexus phone too.. if run same app on phone below 3.0 (gives me error)
08-24 11:47:53.628: e/androidruntime(787): @ android.app.activitythread.performlaunchactivity(activitythread.java:1651) 08-24 11:47:53.628: e/androidruntime(787): @ android.app.activitythread.handlelaunchactivity(activitythread.java:1667) 08-24 11:47:53.628: e/androidruntime(787): @ android.app.activitythread.access$1500(activitythread.java:117) 08-24 11:47:53.628: e/androidruntime(787): @ android.app.activitythread$h.handlemessage(activitythread.java:935) 08-24 11:47:53.628: e/androidruntime(787): @ android.os.handler.dispatchmessage(handler.java:99) 08-24 11:47:53.628: e/androidruntime(787): @ android.os.looper.loop(looper.java:130) 08-24 11:47:53.628: e/androidruntime(787): @ android.app.activitythread.main(activitythread.java:3687) 08-24 11:47:53.628: e/androidruntime(787): @ java.lang.reflect.method.invokenative(native method) 08-24 11:47:53.628: e/androidruntime(787): @ java.lang.reflect.method.invoke(method.java:507) 08-24 11:47:53.628: e/androidruntime(787): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:842) 08-24 11:47:53.628: e/androidruntime(787): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:600) 08-24 11:47:53.628: e/androidruntime(787): @ dalvik.system.nativestart.main(native method) 08-24 11:47:53.628: e/androidruntime(787): caused by: java.lang.nullpointerexception 08-24 11:47:53.628: e/androidruntime(787): @ com.cooliris.media.gallery.oncreate(gallery.java:323) 08-24 11:47:53.628: e/androidruntime(787): @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1047) 08-24 11:47:53.628: e/androidruntime(787): @ android.app.activitythread.performlaunchactivity(activitythread.java:1615) 08-24 11:47:53.628: e/androidruntime(787): ... 11 more
so tried following:
intent intent1= new intent("android.intent.action.main", null); intent1.addcategory("android.intent.category.app_gallery"); intent intent2 = intent.createchooser(intent1, "gallery"); startactivity(intent2);
again works fine phones above/equalto 4.0 version. on 4.0 below phones gives alert notification saying:
"no application can perform action"
can me out opening gallery pressing button app?
i figured out way..
intent intent = new intent(intent.action_view, uri.parse( "content://media/internal/images/media")); startactivity(intent);
this piece of code opened gallery without issues. working on versions!
thought put answer people looking open gallery on versions.
thanks guys! :)
Comments
Post a Comment