我需要一些示例代碼來顯示沒有任何拍照的照相機。 這樣做最簡單的方法是什麼?在你的代碼如何簡單地顯示安卓相機
<uses-permission android:name="android.permission.CAMERA"/>
<uses-feature android:name="android.hardware.camera" />
:
我需要一些示例代碼來顯示沒有任何拍照的照相機。 這樣做最簡單的方法是什麼?在你的代碼如何簡單地顯示安卓相機
<uses-permission android:name="android.permission.CAMERA"/>
<uses-feature android:name="android.hardware.camera" />
:
此鏈接會解釋一切好了很多,比我:http://developer.android.com/guide/topics/media/camera.html
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, CAMERA_REQUEST);
在AndroidManifest.xml中
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, CAMERA_REQUEST);
使用此代碼示例:打開相機
public void open(){
Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent, 0);
}
捕捉圖像:
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
Bitmap bp = (Bitmap) data.getExtras().get("data");
imgFavorite.setImageBitmap(bp);
}
添加權限在清單:
<uses-permission android:name="android.permission.CAMERA"/>
<uses-feature android:name="android.hardware.camera" />
XML:
內的相對佈局採取的ImageView和TextView的
試試這個。
如何在片段中使用 – 2014-09-11 08:03:11
我所做的是創建預覽類:http://developer.android.com/guide/topics/media/camera.html#camera-preview,然後將其放置在佈局中:http ://developer.android.com/guide/topics/media/camera.html#preview-layout – 2014-09-11 08:24:20