Android的接待默认置摄像头摄像头、Android

由网友(╰活的潇洒,笑得放肆)分享简介:好吧,我有一个要去,有一个前置摄像头一个特定的Andr​​oid设备上的应用程序。 我需要在默认情况下使用的前置摄像头。最小API我已经设置为9。我试图寻找无处不在,因为我这样一个新手到JAVA,我迷路了。 下面是我的code片段,如果你能请阐述一下code是如何工作我会AP preciate大大! 进口android...

好吧,我有一个要去,有一个前置摄像头一个特定的Andr​​oid设备上的应用程序。

我需要在默认情况下使用的前置摄像头。最小API我已经设置为9。我试图寻找无处不在,因为我这样一个新手到JAVA,我迷路了。

下面是我的code片段,如果你能请阐述一下code是如何工作我会AP preciate大大!

 进口android.app.Activity;进口android.hardware.Camera;进口android.os.Bundle;进口android.util.Log;进口android.view.Surface;导入org.apache.cordova *。公共类MainActivity扩展DroidGap {    @覆盖    公共无效的onCreate(捆绑savedInstanceState){        super.onCreate(savedInstanceState);        super.loadUrl(文件:///android_asset/www/index.html);    }} 

解决方案 android直接调用摄像头

您需要添加摄像机的权限

 <使用许可权的android:NAME =android.permission.CAMERA/> <使用特征的android:NAME =android.hardware.camera/> <使用特征的android:NAME =android.hardware.camera.autofocus/> 

和相机的是 API和GT = 9 ,所以你没事。这是前置摄像头的意图,在code使用它

  INT CAMERA_FACING_FRONT 

在这里阅读更多: http://developer.android.com/reference/安卓/硬件/ Camera.html

Alright I have an application that is going to go on a specific android device that has a front facing camera.

I need to use the front facing camera by default. The min API I have set is 9. I have tried looking everywhere and since I am such a newbie to JAVA, I am lost.

Here is my code snippet if you could please elaborate on how the code works I will appreciate it greatly!

import android.app.Activity;
import android.hardware.Camera;
import android.os.Bundle;
import android.util.Log;
import android.view.Surface;

import org.apache.cordova.*;

public class MainActivity extends DroidGap {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        super.loadUrl("file:///android_asset/www/index.html");
    }
}

解决方案

You need to add Camera permissions

 <uses-permission android:name="android.permission.CAMERA" />
 <uses-feature android:name="android.hardware.camera" />
 <uses-feature android:name="android.hardware.camera.autofocus" />

and Camera's are for APIs >=9, so you're okay. This is the front Camera intent, use it in your code

int CAMERA_FACING_FRONT 

Read more here: http://developer.android.com/reference/android/hardware/Camera.html

阅读全文

相关推荐

最新文章