views:

1269

answers:

4

Hi,

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
+1  A: 

I don't have much to add, except that I'm running Android 1.5 (Samsung Moment) and it doesn't cause an error. I'm working on a BT application for the Moment (fixing an annoying bug), but it's not working yet. And it may not be enough of an example when I do finally get it working.

Good luck!

Paul K.
+1  A: 

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... :(.

MrSnowflake
A: 

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)"

FeatureCreep
A: 

backport.android.bluetooth.BluetoothAdapter is it working for Android 1.6 ? If yes then please explain?? thanks in advance....

shripal