Java tutorial
//package com.java2s; //License from project: Open Source License import android.app.Activity; import android.content.Intent; import android.provider.MediaStore; public class Main { public static final int SELECT_IMAGE_GALLERY_REQUEST_CODE = 1666; public static void choiceAvatarFromGalleryWithCrop(Activity context) { Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI); intent.setType("image/*"); //intent.setAction(Intent.ACTION_GET_CONTENT); context.startActivityForResult(intent, SELECT_IMAGE_GALLERY_REQUEST_CODE); //if (Build.VERSION.SDK_INT < 19) { // Intent intentPikc = new Intent(); // intentPikc.setType("image/*"); // intentPikc.setAction(Intent.ACTION_GET_CONTENT); // context.startActivityForResult(intentPikc, SELECT_IMAGE_GALLERY_REQUEST_CODE); // } else { // Intent intentKitKat = new Intent(Intent.ACTION_GET_CONTENT); // intentKitKat.setType("image/*"); // context.startActivityForResult(intentKitKat, SELECT_KITKAT_IMAGE_GALLERY_REQUEST_CODE); // } // Intent intent = new Intent(); // intent.setType("image/*"); // Intent intent = new Intent( // Intent.ACTION_GET_CONTENT, // MediaStore.Images.Media.INTERNAL_CONTENT_URI); // intent.setType("image/*"); //// Intent intent = new Intent(Intent.ACTION_PICK, //// android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); //// intent.setAction(Intent.ACTION_GET_CONTENT); // context.startActivityForResult(intent, SELECT_IMAGE_GALLERY_REQUEST_CODE); // Intent intent = new Intent(); // intent.setType("image/*"); // intent.setAction(Intent.ACTION_GET_CONTENT); // context.startActivityForResult(Intent.createChooser(intent, "Select Picture"), SELECT_IMAGE_GALLERY_REQUEST_CODE); } }