Harmonyos 2.0.0的BLE连接
我正在使用Android Studio创建BLE扫描仪,但我似乎无法在手机上要求使用权限。我使用的是华为Harmonyos 2.0.0手机,我的同事正在使用三星Android 11手机,并且在他的手机上正常工作。
我是否需要实施特定的依赖性或为了在手机上工作吗?我看到某个地方,对于位置权限,我们需要实现一个单独的库。 ( >)。对于BLE和蓝牙,这会一样吗?
这些是我目前的依赖性:
dependencies {
implementation 'com.google.android.material:material:1.6.0'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
implementation "androidx.core:core-splashscreen:1.0.0-alpha01"
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.jjoe64:graphview:4.2.2'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对于Android,BLE需要这些权限,包括对设备的扫描:
一个人还应声明对死灵硬件的要求:
在使用Deveco Studio为Harmonyos(本地)建立Harmonyos(本机)时,这有点不同:
它将在
entry> entry/src/main/config.json
中需要这些权限:也有一个codeLab: 如何通过ble 在设备之间启用设备之间的通信
For Android these permissions are required for BLE, including scanning for devices:
And one should also declare the requirement for the neccessary hardware:
When building for HarmonyOS (native) with DevEco Studio, this works a little different:
https://developer.harmonyos.com/en/docs/documentation/doc-guides/connectivity-ble-advertising-0000001051008453
And it would require these permissions in
entry/src/main/config.json
:There's also a codelab: How to Enable Communication Between Devices Through BLE
您没有必须安装的特殊依赖库。我已经在我的华为Mate 30 Pro上尝试了此应用程序(下面的链接),该应用程序是Hamonyos 2.0.0手机,它可以使用。它弹出一个屏幕,要求用户启用蓝牙并允许使用该设备。
如果您仍然有问题,请提供日志文件,电话模型和Harmonyos构建号码。
在这里,我尝试了我尝试过的应用程序
https://github.com/ android/connectivity-samples/tree/master/bluetoothchat
在这里,您想了解更多信息的文章链接。 https://develper..android.com/guide.com/guide/guide/topics/topics/connectivity/connectivity/bluetoothivity/bluetooth/bluetooth
bluetooth Info的Harmonyos版本
但是,为了获得更好的用户体验,建议您使用Deveco Ide huawei huawei版本的iDE来开发特定的iDE,以适用Harmonyos而不是Android Studio
这里的链接以了解更多 https://developer.harmonyos.com/en/
There is no special dependencies libraries that you have to install. I have try this app (link below) on my Huawei Mate 30 pro which is a HamonyOS 2.0.0 phone and it works. It pop up a screen to ask user to enable Bluetooth and give it permission to use the device.
If you still have problem please provide the log file, phone model and HarmonyOS build number.
Here the link to the app I've tried
https://github.com/android/connectivity-samples/tree/master/BluetoothChat
Here the link to the article incase you want to learn more. https://developer.android.com/guide/topics/connectivity/bluetooth
Here HarmonyOS version of Bluetooth info
https://developer.harmonyos.com/en/docs/documentation/doc-guides/connectivity-bluetooth-overview-0000000000029991
However for better user experience it's recommended that you use DevEco IDE Huawei version of IDE that develop specifically to work with HarmonyOS instead of Android Studio
Here the link to learn more https://developer.harmonyos.com/en/