在 Android 1.6 上使用 backport-android-bluetooth

发布于 2024-08-26 04:44:42 字数 3603 浏览 7 评论 0原文

我正在尝试在 Android 1.6 上使用蓝牙编写一个应用程序。由于它不受官方支持,我找到了 android.bluetooth API 的反向移植( http:// code.google.com/p/backport-android-bluetooth )。但是,当我部署示例聊天应用程序(针对反向移植进行修改)时,LogCat 给出了以下错误:

我的问题是,如何在 1.6 上使用 backport-android-bluetooth 以及是否有任何工作示例?

谢谢!

    11-30 14:03:19.890: ERROR/AndroidRuntime(1927): Uncaught handler: thread main exiting due to uncaught exception
11-30 14:03:19.906: ERROR/AndroidRuntime(1927): java.lang.ExceptionInInitializerError
11-30 14:03:19.906: ERROR/AndroidRuntime(1927):     at backport.android.bluetooth.BluetoothSocket.<init>(BluetoothSocket.java:69)
11-30 14:03:19.906: ERROR/AndroidRuntime(1927):     at backport.android.bluetooth.BluetoothServerSocket.<init>(BluetoothServerSocket.java:16)
11-30 14:03:19.906: ERROR/AndroidRuntime(1927):     at backport.android.bluetooth.BluetoothAdapter.listenUsingRfcommWithServiceRecord(BluetoothAdapter.java:513)
11-30 14:03:19.906: ERROR/AndroidRuntime(1927):     at com.example.bluetooth.BluetoothChatService$AcceptThread.<init>(BluetoothChatService.java:237)
11-30 14:03:19.906: ERROR/AndroidRuntime(1927):     at com.example.bluetooth.BluetoothChatService.start(BluetoothChatService.java:109)
11-30 14:03:19.906: ERROR/AndroidRuntime(1927):     at com.example.bluetooth.BluetoothChat.onResume(BluetoothChat.java:138)
11-30 14:03:19.906: ERROR/AndroidRuntime(1927):     at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1225)
11-30 14:03:19.906: ERROR/AndroidRuntime(1927):     at android.app.Activity.performResume(Activity.java:3559)
11-30 14:03:19.906: ERROR/AndroidRuntime(1927):     at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2838)
11-30 14:03:19.906: ERROR/AndroidRuntime(1927):     at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2866)
11-30 14:03:19.906: ERROR/AndroidRuntime(1927):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2420)
11-30 14:03:19.906: ERROR/AndroidRuntime(1927):     at android.app.ActivityThread.access$2100(ActivityThread.java:116)
11-30 14:03:19.906: ERROR/AndroidRuntime(1927):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
11-30 14:03:19.906: ERROR/AndroidRuntime(1927):     at android.os.Handler.dispatchMessage(Handler.java:99)
11-30 14:03:19.906: ERROR/AndroidRuntime(1927):     at android.os.Looper.loop(Looper.java:123)
11-30 14:03:19.906: ERROR/AndroidRuntime(1927):     at android.app.ActivityThread.main(ActivityThread.java:4203)
11-30 14:03:19.906: ERROR/AndroidRuntime(1927):     at java.lang.reflect.Method.invokeNative(Native Method)
11-30 14:03:19.906: ERROR/AndroidRuntime(1927):     at java.lang.reflect.Method.invoke(Method.java:521)
11-30 14:03:19.906: ERROR/AndroidRuntime(1927):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
11-30 14:03:19.906: ERROR/AndroidRuntime(1927):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
11-30 14:03:19.906: ERROR/AndroidRuntime(1927):     at dalvik.system.NativeStart.main(Native Method)
11-30 14:03:19.906: ERROR/AndroidRuntime(1927): Caused by: java.lang.UnsatisfiedLinkError: classInitNative
11-30 14:03:19.906: ERROR/AndroidRuntime(1927):     at android.bluetooth.RfcommSocket.classInitNative(Native Method)
11-30 14:03:19.906: ERROR/AndroidRuntime(1927):     at android.bluetooth.RfcommSocket.<clinit>(RfcommSocket.java:152)
11-30 14:03:19.906: ERROR/AndroidRuntime(1927):     ... 21 more

I'm trying to write an application using Bluetooth on Android 1.6. Since it's not officially supported, I found the backport of android.bluetooth API ( http://code.google.com/p/backport-android-bluetooth ). But when I deploy the sample chat application (modified for backport) LogCat gives me the error below:

My question is, how I can use backport-android-bluetooth on 1.6 and is there any working samples?

Thanks!

    11-30 14:03:19.890: ERROR/AndroidRuntime(1927): Uncaught handler: thread main exiting due to uncaught exception
11-30 14:03:19.906: ERROR/AndroidRuntime(1927): java.lang.ExceptionInInitializerError
11-30 14:03:19.906: ERROR/AndroidRuntime(1927):     at backport.android.bluetooth.BluetoothSocket.<init>(BluetoothSocket.java:69)
11-30 14:03:19.906: ERROR/AndroidRuntime(1927):     at backport.android.bluetooth.BluetoothServerSocket.<init>(BluetoothServerSocket.java:16)
11-30 14:03:19.906: ERROR/AndroidRuntime(1927):     at backport.android.bluetooth.BluetoothAdapter.listenUsingRfcommWithServiceRecord(BluetoothAdapter.java:513)
11-30 14:03:19.906: ERROR/AndroidRuntime(1927):     at com.example.bluetooth.BluetoothChatService$AcceptThread.<init>(BluetoothChatService.java:237)
11-30 14:03:19.906: ERROR/AndroidRuntime(1927):     at com.example.bluetooth.BluetoothChatService.start(BluetoothChatService.java:109)
11-30 14:03:19.906: ERROR/AndroidRuntime(1927):     at com.example.bluetooth.BluetoothChat.onResume(BluetoothChat.java:138)
11-30 14:03:19.906: ERROR/AndroidRuntime(1927):     at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1225)
11-30 14:03:19.906: ERROR/AndroidRuntime(1927):     at android.app.Activity.performResume(Activity.java:3559)
11-30 14:03:19.906: ERROR/AndroidRuntime(1927):     at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2838)
11-30 14:03:19.906: ERROR/AndroidRuntime(1927):     at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2866)
11-30 14:03:19.906: ERROR/AndroidRuntime(1927):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2420)
11-30 14:03:19.906: ERROR/AndroidRuntime(1927):     at android.app.ActivityThread.access$2100(ActivityThread.java:116)
11-30 14:03:19.906: ERROR/AndroidRuntime(1927):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
11-30 14:03:19.906: ERROR/AndroidRuntime(1927):     at android.os.Handler.dispatchMessage(Handler.java:99)
11-30 14:03:19.906: ERROR/AndroidRuntime(1927):     at android.os.Looper.loop(Looper.java:123)
11-30 14:03:19.906: ERROR/AndroidRuntime(1927):     at android.app.ActivityThread.main(ActivityThread.java:4203)
11-30 14:03:19.906: ERROR/AndroidRuntime(1927):     at java.lang.reflect.Method.invokeNative(Native Method)
11-30 14:03:19.906: ERROR/AndroidRuntime(1927):     at java.lang.reflect.Method.invoke(Method.java:521)
11-30 14:03:19.906: ERROR/AndroidRuntime(1927):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
11-30 14:03:19.906: ERROR/AndroidRuntime(1927):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
11-30 14:03:19.906: ERROR/AndroidRuntime(1927):     at dalvik.system.NativeStart.main(Native Method)
11-30 14:03:19.906: ERROR/AndroidRuntime(1927): Caused by: java.lang.UnsatisfiedLinkError: classInitNative
11-30 14:03:19.906: ERROR/AndroidRuntime(1927):     at android.bluetooth.RfcommSocket.classInitNative(Native Method)
11-30 14:03:19.906: ERROR/AndroidRuntime(1927):     at android.bluetooth.RfcommSocket.<clinit>(RfcommSocket.java:152)
11-30 14:03:19.906: ERROR/AndroidRuntime(1927):     ... 21 more

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

深居我梦 2024-09-02 04:44:42

我认为这个反向移植蓝牙不起作用,因为 1.6 屏蔽了使用的 api。这是 Google 对 1.6 所做的更新之一:阻止开发人员使用内部 api,我猜 BT 就是其中之一......:(。

I think this backport bluetooth doesn't work, because 1.6 shields off the used api's. It's one of the updates Google did to 1.6: prevent developers to use internal api's and I guess BT is one of them... :(.

奶茶白久 2024-09-02 04:44:42

根据蓝牙反向移植的此问题 tracker 在 1.6 上应该可以实现。引用:“我在 HTC Magic (Android 1.6) 上成功运行了向后移植”

According to this issue on the bluetooth backport tracker it should be possible to it on 1.6. Quote: "I run the backport successfully on a HTC Magic (Android 1.6)"

萌︼了一个春 2024-09-02 04:44:42

向后移植 API 适用于 android 1.6。按照项目主页上给出的说明进行操作。我尝试使用蓝牙聊天示例应用程序并且工作正常。

The backport api works on android 1.6. Follow the instructions given on project home page. I tried with bluetooth chat sample app and works fine.

原谅过去的我 2024-09-02 04:44:42

我使用这个库已经很长时间了 - 它可以在某些手机上运行,​​但不能在其他手机上运行。这实际上取决于底层的 Android 构建..

I am using this lib since a long time - It works on some phones, but not on others. It really depends on the underlying Android Build ..

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文