十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
1 public void cropImage(View view){
2 Intent intent = new Intent();
3
4 Bundle myExtras = new Bundle();
5 myExtras.putBoolean("return-data", true);
6 intent.putExtras(myExtras);
7
8
9 intent.setAction("com.android.camera.action.CROP");
10 intent.addCategory("android.intent.category.DEFAULT");
11 // intent.setData(Uri.fromFile(new File("sdcard/img.JPG")));
12 // intent.setType("image/*");13 intent.setDataAndType(Uri.fromFile(new File("sdcard/img.JPG")),"image/*");
14 startActivityForResult(intent, 0);
15 }
16
17 @Override
18 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
19 if(data!=null){
20 Parcelable imagedata = (Parcelable) data.getExtras().get("data");
21 iv.setImageBitmap((Bitmap) imagedata);
22
23 }
24 super.onActivityResult(requestCode, resultCode, data);
25 }