Intent takePicIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
Intent pickPicIntent = new Intent(Intent.ACTION_GET_CONTENT);
pickPicIntent.setType("image/*");
Intent chooserIntent = Intent.createChooser(takePicIntent, "Choose intent");
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[]{pickPicIntent});
startActivityForResult(chooserIntent, REQUEST_CODE);
启动的多余的Intent用数组的形式组合起来,传递给createChooser.
很多App都有这样一个分享图片的功能,图片的来源要么是直接从摄像头获取,要么是从相册里面选择,一个很简便实现这种功能的的方式是通过Intent提供的createChooser方法,ok,here we go,let's see the code:
转载于:https://my.oschina.net/javaTechLover/blog/341651