代码A来自CameraX项目,你可以看到source code .
当我删除 @SuppressLint("RestrictedApi")
时,Android Studio 将显示“只能从同一个库组中调用” ,您可以看到图 1。
为什么我不能删除 @SuppressLint("RestrictedApi")
在代码 A 中? deos 限制 API 是什么意思?
代码 A
@SuppressLint("RestrictedApi")
private fun updateCameraUi() {
...
// Listener for button used to switch cameras
controls.findViewById<ImageButton>(R.id.camera_switch_button).setOnClickListener {
lensFacing = if (CameraX.LensFacing.FRONT == lensFacing) {
CameraX.LensFacing.BACK
} else {
CameraX.LensFacing.FRONT
}
try {
// Only bind use cases if we can query a camera with this orientation
CameraX.getCameraWithLensFacing(lensFacing)
// Unbind all use cases and bind them again with the new lens facing configuration
CameraX.unbindAll()
bindCameraUseCases()
} catch (exc: Exception) {
// Do nothing
}
}
}
图片 1
最佳答案
自本教程制作以来,库中发生了重大变化。
将软件包版本恢复为 1.0.0-alpha06
,和教程一样,解决了问题。
关于android - 为什么当我删除 @SuppressLint "only be called from with the same library group"时 Android Studio 会显示 ("RestrictedApi")?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58567716/