本文实例讲述了Android实现返回拍摄的图片功能。分享给大家供大家参考。具体如下:
第一步:
1
2
3
4
5
6
7
|
try {
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent, 0 );
} catch (ActivityNotFoundException e) {
// Do nothing for now
}
|
第二步:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
@Override
protected void onActivityResult( int requestCode, int resultCode, Intent data) {
try {
if (requestCode != 0 ) {
return ;
}
super .onActivityResult(requestCode, resultCode, data);
Bundle extras = data.getExtras();
Bitmap b = (Bitmap) extras.get( "data" );
//
//
ImageView a = (ImageView)findViewById(R.id.imageView1);
a.setImageBitmap(b);
//
/*
* 得到图片对图片处理...
*/
} catch (Exception e) {
// TODO: handle exception
System.out.println(e.getMessage());
}
}
|
希望本文所述对大家的Android程序设计有所帮助。