Android中調用相冊裡面的圖片並返回:
Intent intent=new Intent(Intent.ACTION_GET_CONTENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("image/*");
intent.putExtra("crop", "true");
intent.putExtra("aspectX", 1);
intent.putExtra("aspectY", 1);
intent.putExtra("outputX", 80);
intent.putExtra("outputY", 80);
intent.putExtra("return-data", true);
startActivityForResult(intent, 0);
在原來的Activity中如下獲取選到的圖片:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
System.out.println(resultCode);
Bitmap cameraBitmap = (Bitmap) data.getExtras().get("data");
super.onActivityResult(requestCode, resultCode, data);
}
更多Android相關信息見Android 專題頁面 http://www.linuxidc.com/topicnews.aspx?tid=11