如果只需调用相机,把你的 Intent i = new Intent(Intent.ACTION_GET_CONTENT); i.addCategory(Intent.CATEGORY_OPENABLE); i.setType("image/*"); 换成下面的就可以了 Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
/** * 弹出选择相册对话框 * 接收文件重写:public void actResultAlbum(File file) {} */ public void showAlbumChooser() { Intent intent = new Intent(Intent.ACTION_PICK, null); intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*"); startActivityForResult(intent, ACT_RESULT_ALBUM); } public void actResultAlbum(File file) {}
Intent i = new Intent(Intent.ACTION_GET_CONTENT);
i.addCategory(Intent.CATEGORY_OPENABLE);
i.setType("image/*");
换成下面的就可以了
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
* 弹出选择相册对话框
* 接收文件重写:public void actResultAlbum(File file) {}
*/
public void showAlbumChooser() {
Intent intent = new Intent(Intent.ACTION_PICK, null);
intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*");
startActivityForResult(intent, ACT_RESULT_ALBUM);
}
public void actResultAlbum(File file) {}
/**
* 拍照界面
* 接收文件重写:public void actResultCamera(File file) {}
*/
public void showCameraChooser() throws Exception {
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(fileUtil.getRoot() + "/temp.jpg")));
startActivityForResult(intent, ACT_RESULT_CAMERA);
}
public void actResultCamera(File file) {}
/**
* 打开剪切图片的页面
* @param file 剪切的原图片文件
* @param size 剪切的尺寸大小
* @param activity 容器
*/
public void showCutImg(File file, int size, Activity activity) {
Intent intent = new Intent("com.android.camera.action.CROP");
intent.setDataAndType(Uri.fromFile(file), "image/*");
intent.putExtra("crop", true);
intent.putExtra("aspectX", 1);
intent.putExtra("aspectY", 1);
intent.putExtra("outputX", size);
intent.putExtra("outputY", size);
intent.putExtra("return-data", true);
activity.startActivityForResult(intent, AbstractActivity.ACT_RESULT_CUT_IMG);
} /**
* 裁剪图片后的事件,使用时请重写该方法
* @param bitmap 获得裁剪的图片
*/
public void actResultCutImg(Bitmap bitmap) {}
我是需要在这两个中增加一个相机功能。。相机,图库,文件管理,这三个应用之间没有共同的Action,所以不能同时获取得到,这是我所理解的。有一种办法就是:获取launcher里面的应用,寻找分别满足这三种Intent的应用。