Android的摄像头preVIEW教程 [英] Android camera preview tutorial

查看:202
本文介绍了Android的摄像头preVIEW教程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有,我跟着一个教程豆蔻问题。我想要用相机preVIEW一个Android应用程序,但是到现在为止我还没有发现任何好的教程,说明如何做到这一点。这里是链接教程
我不太舒尔如果我可以使用相机意图insted的相机preveiew的?我该怎么办。

I have a litte problem with a tutorial that I follow. I want to make a android application with a camera preview, but until now I haven't found any good tutorial that show how to do it. Here is the link The tutorial I'm not quite shure if I can use the "camera with intent" insted of the "camera preveiew" ? What do I do.

谢谢:)

推荐答案

下面教程会帮助你。

<一个href=\"http://www.vogella.com/articles/AndroidCamera/article.html\">http://www.vogella.com/articles/AndroidCamera/article.html

<一个href=\"http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/graphics/Camera$p$pview.html\">http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/graphics/Camera$p$pview.html

电话内置摄像头的意图有图片。

Call inbuilt camera intent to have picture.

public class demo extends Activity {

Button ButtonClick;
int CAMERA_PIC_REQUEST = 1337; 


@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    ButtonClick =(Button) findViewById(R.id.Camera);
    ButtonClick.setOnClickListener(new OnClickListener (){
        @Override
        public void onClick(View view)
        {
            Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
            // request code

            startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST);

        }
    });

}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) 
{
    if( requestCode == 1337)
    {
    //  data.getExtras()
        Bitmap thumbnail = (Bitmap) data.getExtras().get("data");

          Now you have received the bitmap..you can pass that bitmap to other activity
          and play with it in this activity or pass this bitmap to other activity
          and then upload it to server.
    }
    else 
    {
        Toast.makeText(demo.this, "Picture NOt taken", Toast.LENGTH_LONG);
    }
    super.onActivityResult(requestCode, resultCode, data);
}
}

这篇关于Android的摄像头preVIEW教程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆