当前位置: 代码迷 >> Android >> pro.Android Media-调用内置的相机
  详细解决方案

pro.Android Media-调用内置的相机

热度:85   发布时间:2016-05-01 19:37:15.0
pro.Android Media--调用内置的照相机

内置的照相机程序在manifest定义了下面的intent filter

<intent-filter> <action android:name="android.media.action.IMAGE_CAPTURE" /> <category android:name="android.intent.category.DEFAULT" /></intent-filter>

?

所以只需要用对应的intent启动就可以了

?

下面的android.provider.MediaStore.ACTION_IMAGE_CAPTURE = "android.media.action.IMAGE_CAPTURE";

?

public class CameraIntent extends Activity {	final static int CAMERA_RESULT = 0;	ImageView mImagevView;		@Override	protected void onCreate(Bundle savedInstanceState) {		super.onCreate(savedInstanceState);				setContentView(R.layout.ch1);				Intent i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);		startActivityForResult(i, CAMERA_RESULT);	}		@Override	protected void onActivityResult(int requestCode, int resultCode, Intent data) {		super.onActivityResult(requestCode, resultCode, data);				if(resultCode == RESULT_OK){			//get extras from the intent			Bundle extra = data.getExtras();			//get the returned image from the extras			Bitmap b = (Bitmap)extra.get("data");						mImagevView = (ImageView)findViewById(R.id.returnedImageView);			mImagevView.setImageBitmap(b);					}	}}
  相关解决方案