package com.example.camera; import android.os.Bundle; import android.widget.ImageView; import android.app.Activity; import android.content.Intent; import android.graphics.Bitmap; public class MainActivity extends Activity { private final static int CAMERA_RESULT =0; private ImageView view; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); view=(ImageView)findViewById(R.id.imageview); Intent i=new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);//启动intent startActivityForResult(i, CAMERA_RESULT); } //返回接收 @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { // TODO Auto-generated method stub super.onActivityResult(requestCode, resultCode, data); if(resultCode==RESULT_OK){ Bundle bundle=data.getExtras(); Bitmap bitmap=(Bitmap) bundle.get("data"); view.setImageBitmap(bitmap); } } }
android camera的简单demo
最新推荐文章于 2024-09-04 21:01:10 发布