Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

安卓端demo自动退出 #15

Open
YjDai opened this issue Jul 6, 2018 · 4 comments
Open

安卓端demo自动退出 #15

YjDai opened this issue Jul 6, 2018 · 4 comments

Comments

@YjDai
Copy link

YjDai commented Jul 6, 2018

你好,想问一下,调试了一下安卓端的demo,手机摄像头权限什么都打开了,但是每次点击“打开相机,活体检测”按钮,就会自动退出?

@SaddamBInSyed
Copy link

Me2 the same above problem. running apk on RedMiNote4 (MI brand)

@ZivenMan
Copy link

那是因为老的android API采用摄像头运行时授权。在Detection.java打开摄像头那行camera = Camera.open(1);之前添加:
if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA)
== PackageManager.PERMISSION_GRANTED) {
Log.i("TEST","Granted");
//init(barcodeScannerView, getIntent(), null);
} else {
ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.CAMERA}, 1);//1 can be another integer
}
同时引入包:import android.support.v4.app.ActivityCompat;

参见: 《Android 6 camera.open()异常解决方法》

@panda-lab
Copy link

@ZivenMan Hi,非常感谢你的热心,能否把你运行没有问题的代码帮我们提交一个PR?多谢。

@sunmoonb
Copy link

sunmoonb commented Jan 8, 2019

@YjDai 请问下,你这个问题解决了吗?我最近也遇到同样的问题。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants