Java tutorial
//package com.java2s; //License from project: Apache License import android.app.Activity; import android.content.Context; import android.content.Intent; import android.provider.MediaStore; public class Main { public static void chooserPics(Context context, int requestCode) { if (context == null) { return; } try { Intent localIntent = new Intent(); localIntent.setData(MediaStore.Images.Media.EXTERNAL_CONTENT_URI); localIntent.setType("image/*"); localIntent.setAction(Intent.ACTION_GET_CONTENT); if (context instanceof Activity) { ((Activity) context).startActivityForResult(Intent.createChooser(localIntent, "Select Picture"), requestCode); } else { localIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(Intent.createChooser(localIntent, "Select Picture")); } } catch (Exception e) { } } }