首页 > 编程知识 正文

android 双摄像头 开发,android应用调用摄像头

时间:2023-05-04 22:01:42 阅读:141545 作者:4540

不幸的是,在互联网上使用照相机时可以设置以下附加参数

MediaStore.EXTRA_OUTPUT

例如

fileuri=getoutputmediafileuri (media _ type _ image ); //create a file to save the image

intent.put extra (mediastore.extra _ output,fileUri ); //set the image file name

这使您可以映射camera APP应用程序存储映像的位置。

即使面对额外的意图,摄像头也可能正常工作:

action.put extra (Android.intent.extras.camera _ facing ',1 );

查看android源文件时,Util类文件中有几种“测试”方法,但没有正式记录:

(使用率)

privatestaticfinalstringextras _ camera _ facing=

' Android.intent.extras.camera _ facing ';

//thisisfortestonly.allowthecameratolaunchthespecificcamera。

publicstaticintgetcamerafacingintentextras (activitycurrentactivity )

int cameraId=-1;

int intentCameraId=

current activity.get intent (.getint extra (util.extras _ camera _ facing,-1);

iffrontcameraintent (intentcameraid ) }

//Check if the front camera exist

intfront cameraid=camera holder.instance ().getFrontCameraId;

前摄影机!=-1({

cameraId=frontCameraId;

}

} else if (isbackcameraintent (intentcameraid ) )。

//Check if the back camera exist

intbackcameraid=camera holder.instance ().getBackCameraId;

备份卡!=-1({

cameraId=backCameraId;

}

}

return cameraId;

}

photomodule使用以下方法:

(PhotoModule )

privateintgetpreferredcameraid (combopreferencespreferences ) (

intintentcameraid=util.getcamerafacingintentextras (mactivity );

国际摄像头!=-1({

//testing purpose.launchaspecificcamerathroughtheintent

//extras。

return intentCameraId;

} else {

returncamerasettings.readpreferredcameraid (preferences;

}

}

照相机APP初始化照片模式后,调用此方法以检查要使用的照相机。

mame raid=getpreferredcameraid (mpreferences;

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。