有没有什么办法做一个安全的意图相机所有级别的API? [英] Is there any way to do a safe intent to camera for all level apis?
本文介绍了有没有什么办法做一个安全的意图相机所有级别的API?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
从Froyo的冰淇淋三明治,这是方式:
From Froyo to Ice Cream Sandwich this is the way:
Intent intent = new
Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File file = new File(Environment.getExternalStorageDirectory(), "test.jpg");
tempUriCameraDeviceNotSuported = Uri.fromFile(file);
intent.putExtra(MediaStore.EXTRA_OUTPUT,
tempUriCameraDeviceNotSuported);
startActivityForResult(intent, 0);
但对于果冻豆它不工作,你必须做这样的事情:
But for Jelly Bean it doesn't work, you must do something like this:
Intent takePicture = new Intent(
MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(takePicture, 0);
我不知道,如果这个bug只发生在果冻豆,或者它也取决于硬件模型。谷歌并没有讲述一个关于这个问题的话(为什么?为什么?)。有人知道我在哪里可以找到所有设备及其权相机实现一个列表?有人知道做到这一点的最好方法是什么?
I'm not sure if this bug happens only in jelly bean, or it also depends on the hardware model. Google doesn't tell a word about this issue (why? why?). Someone knows where can I find a list with all devices and their right camera implementation? Someone knows the best way to do this?
推荐答案
您可以随时检查操作系统版本:
You can always check for the OS version:
if (android.os.Build.VERSION.SDK_INT >= 17) {
Intent takePicture = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(takePicture, 0);
} else {
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File file = new File(Environment.getExternalStorageDirectory(),
"test.jpg");
tempUriCameraDeviceNotSuported = Uri.fromFile(file);
intent.putExtra(MediaStore.EXTRA_OUTPUT,
tempUriCameraDeviceNotSuported);
startActivityForResult(intent, 0);
}
这篇关于有没有什么办法做一个安全的意图相机所有级别的API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文