마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

카메라 연동시..질문..

0 추천

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..

 

도데체..왜 안되는지 모르겠습니다 ㅠㅠㅠㅠ

미치것어요 살려주세요 고수님들..........ㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠ

그리구.. 디바이스에서 디버깅시.. 로그가 왜안뜨는지;;;; 모르겟네요;

mamongs (4,050 포인트) 님이 2013년 3월 13일 질문

답변 달기

· 글에 소스 코드 보기 좋게 넣는 법
· 질문에 대해 추가적인 질문이나 의견이 있으면 답변이 아니라 댓글로 달아주시기 바랍니다.
표시할 이름 (옵션):
개인정보: 당신의 이메일은 이 알림을 보내는데만 사용됩니다.
스팸 차단 검사:
스팸 검사를 다시 받지 않으려면 로그인하거나 혹은 가입 하세요.
...