How to open gallery via intent without result?

前端 未结 4 2168
后悔当初
后悔当初 2020-12-17 05:46

I have a kind of an ApplicationLauncher that has to start the build-in gallery. But I don\'t want to get any result from that gallery. I just want to start it and want my &q

4条回答
  •  轮回少年
    2020-12-17 06:12

    Since it doesn't seem to be possible to open the gallery via an Intent to just browse pictures (without the intent to select one which is then passed back to your application) like when starting the gallery from the launcher, the only solution I found is to explicitly state the package and Activity name in the Intent. For example:

    // For Android 4.0 (Samsung Galaxy Nexus)
    final Intent intent = new Intent();
    intent.setClassName("com.google.android.gallery3d", "com.android.gallery3d.app.Gallery");
    startActivity(intent);
    

    or

    // For Samsung Galaxy S2
    final Intent intent = new Intent();
    intent.setClassName("com.cooliris.media", "com.cooliris.media.Gallery");
    startActivity(intent);
    

    Of course this solution isn't flexible at all and you would have to keep a list of package/activity names in your application and sending Intents (catching ActivityNotFoundException) until you found the right one.

提交回复
热议问题