照相權限和判斷設備是否有相機功能

看官方API發現的一行,記錄下來

<manifest ... >
    <uses-feature android:name="android.hardware.camera" />
    ...
</manifest ... >

文檔說調用相機功能要增加這行到配置文件裏,表明用到相機功能。(貌似根據網上例子沒加這個也能打開默認相機功能。)


It's then your responsibility to check for the availabilityof the camera at runtime by callinghasSystemFeature(PackageManager.FEATURE_CAMERA).If a camera is not available, you should then disable your camera features.


要通過這個來檢查設備是否有照相機功能,沒有的話就要根據情況調整,或者是關閉相機功能,避免出錯。


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章