[android]代码库
//调用相机
public void startCamera(View v){
Intent it=new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(it, 0);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
if(requestCode==0){
Bitmap bitmap=data.getParcelableExtra("data");
imageView.setImageBitmap(bitmap);
}
}
//调用相册
public void but(View v){
Intent it=new Intent(Intent.ACTION_PICK);
it.setType("image/*");
startActivityForResult(it, 0);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
if(requestCode==0){
Uri uri=data.getData();
imageView.setImageURI(uri);
}
}
初级程序员
by: 云代码会员 发表于:2017-04-10 12:47:35 顶(0) | 踩(0) 回复
这正是我需要的
回复评论