网上大部分的文章是这样写的:

Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);      

intent.putExtra("camerasensortype", 2); // 调用前置摄像头  

测试后发现不正确,并不能直接打开前置摄像头,打开的还是后置。正确方法是

Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra("android.intent.extras.CAMERA_FACING", 1);//前置摄像头

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐