Awareness Kit让你的音乐APP脱颖而出,更懂用户,也更动人心 (2)

  获取用户当前的活动状态以推荐歌单:

Awareness.getCaptureClient(context).getBehavior() .addOnSuccessListener(behaviorResponse -> { BehaviorStatus behaviorStatus = behaviorResponse.getBehaviorStatus(); DetectedBehavior mostLikelyBehavior = behaviorStatus.getMostLikelyBehavior(); String str = "Most likely behavior is " + mostLikelyBehavior.getType(); }) .addOnFailureListener(e -> { //获取活动状态失败 Log.e(TAG, "Failed to get the behavior.", e); });

  获取当前是否是连接车载蓝牙:

int deviceType = 0; // 0 代表获取的设备类型为车载蓝牙 Awareness.getCaptureClient(this).getBluetoothStatus(deviceType) .addOnSuccessListener(bluetoothStatusResponse -> { BluetoothStatus bluetoothStatus = bluetoothStatusResponse.getBluetoothStatus(); int status = bluetoothStatus.getStatus(); if (status == BluetoothStatus.CONNECTED) { //当前是连接车载蓝牙,可将app切换为车载模式 } }) .addOnFailureListener(e -> { //获取车载蓝牙状态失败 Log.e(TAG, "Failed to get Bluetooth status.", e); });

往期链接:一文搞懂文本识别、银行卡识别、通用卡证识别、身份证识别
内容来源:https://developer.huawei.com/consumer/cn/forum/topicview?fid=18&tid=0201246052748810283&pid=0301246052748810253
原作者:Ascend

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wpjxwj.html