小编Vij*_*ole的帖子

在 Android 中使用 androidx Biometric API 进行人脸认证

我需要使用指纹和人脸身份验证来集成生物识别身份验证。指纹认证工作完美,但当我只设置人脸认证时,我从 BiometricManager.from(context) 方法得到生物识别未注册响应,如下所示,

val biometricManager = BiometricManager.from(context)
    when(biometricManager.canAuthenticate()){
        BiometricManager.BIOMETRIC_SUCCESS ->{
            Log.e(TAG, "App can authenticate using biometrics.")
        }
        BiometricManager.BIOMETRIC_ERROR_NO_HARDWARE ->{
            Log.d(TAG, "Hardware not available")
        }
        BiometricManager.BIOMETRIC_ERROR_HW_UNAVAILABLE ->{
            Log.d(TAG, "Biometric features are currently unavailable.")
        }
        BiometricManager.BIOMETRIC_ERROR_NONE_ENROLLED ->{
            Log.d(TAG, "The user hasn't associated any biometric credentials with their account.")
        }
        else ->{
            Log.d(TAG, "Nothing supported")
        }
    }
Run Code Online (Sandbox Code Playgroud)

android kotlin android-biometric-prompt android-biometric

7
推荐指数
2
解决办法
3416
查看次数

前台服务重启后多次接收BluetoothGattCallback

我正在使用支持BLE的硬件,并使用Android的Foreground Service与该硬件进行通信。前台服务负责处理BLE相关事件,并且在一段时间内按照要求运行良好,但是由于某种原因,如果前台服务被杀死或BLE连接断开,则应用会尝试再次重新连接到BLE,然后BLE回调开始从BluetoothGattCallback获取重复事件,即使硬件将单个事件发送到Bluetooth,但Android BluetoothGattCallback接收到相同的多个回调,这在我们的实现中导致很多错误。

作为参考,请按以下方式查看日志,

Following are methods and callbacks from my foreground service,

BLEManagerService: *****onDescriptorWrite: 0*****<br>
BLEManagerService: *****onDescriptorWrite: 0*****<br>
BLEManagerService: *****onDescriptorWrite: 0*****<br>
BLEManagerService: Firmware: onCharacteristicRead true<br>
BLEManagerService: *****onDescriptorWrite: 0*****<br>
BLEManagerService: Firmware: onCharacteristicRead true<br>
BLEManagerService: *****onCharacteristicRead: 0*****<br>
BLEManagerService: *****onCharacteristicRead: 0*****<br>
Run Code Online (Sandbox Code Playgroud)

override fun onCreate() {
    super.onCreate()

    mBluetoothGatt?.let { refreshDeviceCache(it) }

    registerReceiver(btStateBroadcastReceiver, IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED))
}

    /**
 * Start BLE scan
 */
private fun scanLeDevice(enable: Boolean) {
    if (enable && bleConnectionState == DISCONNECTED) {
        //initialize scanning BLE
        startScan()
        scanTimer = scanTimer()
    } else {
        stopScan("scanLeDevice: …
Run Code Online (Sandbox Code Playgroud)

android bluetooth-lowenergy

5
推荐指数
1
解决办法
179
查看次数

使用 DownloadManager 下载视频文件时,应用程序在 Android 10 上崩溃

设置时应用程序崩溃 setDestinationInExternalPublicDir()

 val videoDir = Environment.getDataDirectory().absolutePath + "/applicationfiles/.tutorial"
downloadRequest.setDestinationInExternalPublicDir(videoDir, videoName)
Run Code Online (Sandbox Code Playgroud)

E/AndroidRuntime: FATAL EXCEPTION: main Process: app.package, PID: 19275 java.lang.IllegalStateException: 不是标准目录之一: /data/applicationfiles/.tutorial at android.os.Parcel.createException(Parcel.java:2079 ) 在 android.os.Parcel.readException(Parcel.java:2039) 在 android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:188) 在 android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:140) 在 android.content .ContentProviderProxy.call(ContentProviderNative.java:658) at android.content.ContentProviderClient.call(ContentProviderClient.java:558) at android.content.ContentProviderClient.call(ContentProviderClient.java:546) at android.app.DownloadManager$Request。 setDestinationInExternalPublicDir(DownloadManager.java:569) at app.package.startDownloadingFile(ExerciseTutorialPresenter.kt:159) at app.package.downloadVideoFiles(ExerciseTutorialPresenter.kt:142)

android download-manager android-download-manager

4
推荐指数
1
解决办法
2816
查看次数