獲取Android設(shè)備上的詳細(xì)的攝像頭信息
package=wjh.android.takepicture
android:versionCode=1
android:versionName=1.0>
package=wjh.android.takepicture
android:versionCode=1
android:versionName=1.0>
** main.xml
view plaincopy to clipboardprint?
android:orientation=vertical
android:layout_width=fill_parent
android:layout_height=fill_parent
>
android:layout_width=fill_parent
android:layout_height=fill_parent
/>
android:orientation=vertical
android:layout_width=fill_parent
android:layout_height=fill_parent
>
android:layout_width=fill_parent
android:layout_height=fill_parent
/>
** MainActicity
view plaincopy to clipboardprint?
public class MainActicity extends Activity {
private Camera camera;
private boolean preview = false ;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
/*
*設(shè)置窗口屬性:一定要在 setContentView(R.layout.main) 之前
*/
// 窗口標(biāo)題
requestWindowFeature(Window.FEATURE_NO_TITLE);
// 全屏
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main);
SurfaceView surfaceView = (SurfaceView) findViewById(R.id.surfaceView);
surfaceView.getHolder().setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
surfaceView.getHolder().setFixedSize(176, 164);
surfaceView.getHolder().addCallback(new SurfaceViewCallback());
}
private final class SurfaceViewCallback implements Callback {
/**
* surfaceView 被創(chuàng)建成功后調(diào)用此方法
*/
@Override
public void surfaceCreated(SurfaceHolder holder) {
/*
* 在SurfaceView創(chuàng)建好之后 打開攝像頭
* 注意是 android.hardware.Camera
*/
camera = Camera.open();
Camera.Parameters parameters = camera.getParameters();
評論