public class CameraActivity extends Activity {
private Preview mPreview;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// TODO Auto-generated method stub
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.camera_preview);
mPreview = (Preview)findViewById(R.id.camera_preview);
}
}
액티비티..
public class Preview extends SurfaceView implements SurfaceHolder.Callback {
SurfaceHolder mHolder;
Camera mCamera = null;
public Preview(Context context) {
super(context);
// TODO Auto-generated constructor stub
try{
mHolder = getHolder();
mHolder.addCallback(this);
mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
}catch (Exception e) {
// TODO: handle exception
Log.d("ErrorLog ","PreView : Preview" );
}
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
// TODO Auto-generated method stub
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width,
int height) {
// TODO Auto-generated method stub
Camera.Parameters parameters = mCamera.getParameters();
parameters.setPreviewSize(width, height);
mCamera.setParameters(parameters);
mCamera.startPreview();
}
@Override
public void surfaceCreated(SurfaceHolder holder) {
// TODO Auto-generated method stub
mCamera = Camera.open();
try{
mCamera.setPreviewDisplay(holder);
}catch (Exception e) {
// TODO: handle exception
Log.d("ErrorLog", "Preview : surfaceCreated");
mCamera.release();
mCamera = null;
}
}
@Override
public void surfaceDestroyed(SurfaceHolder holder) {
// TODO Auto-generated method stub
mCamera.stopPreview();
mCamera.release();
mCamera = null;
}
}
서페이스.. 프리뷰..
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.bingsubingsu.activity"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="15" />
<uses-permission android:name="android.permission.CAMERA"/>
<uses-feature android:name="android.hardware.camera"/>
<uses-feature android:name="android.hardware.camera.autofocus"/>
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".Intro"
android:label="@string/title_activity_intro" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".login.UserJoinActivity"></activity>
<activity android:name=".login.Login_loddingActivity"></activity>
<activity android:name=".login.LoginFormActivity"></activity>
<activity android:name="MainActivity"></activity>
<activity android:name="CameraActivity"></activity>
</application>
</manifest>
manifest..
도데체..왜 안되는지 모르겠습니다 ㅠㅠㅠㅠ
미치것어요 살려주세요 고수님들..........ㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠ
그리구.. 디바이스에서 디버깅시.. 로그가 왜안뜨는지;;;; 모르겟네요;