I've got a library built by another developer. I have the source, but I'd rather not hack it up in case he releases any updates that might over-write my changes. But he's got some problematic code in it. Namely:
public BluetoothSocket createSocket(final BluetoothDevice device) throws IOException { try { // We're trying to create an insecure socket, which is // only supported // in API 10 and up. If we fail, we try a secure socket // with is in API // 7 and up. return device.createInsecureRfcommSocketToServiceRecord(UUID .fromString("00001101-0000-1000-8000-00805F9B34FB")); } catch (NoSuchMethodError e) { return device.createRfcommSocketToServiceRecord(UUID .fromString("00001101-0000-1000-8000-00805F9B34FB")); } } When I was building at API 10 and running on Android 2.3.3 everything was fine. But I want this code to run on Android 2.2.2 (API 8). If I try to build with API 8 (all my code will work on either API version) I get a build error complaining about createInsecureRfcommSocketToServiceRecord, which did not exist in 8. But if I build with API 10 on run on Android 2.2.2 then my MainActivity throws a ClassNotFoundException. Something in the Activity constructor for API 10 is barfing in Android 2.2.2, which I guess is no real surprise. Is there a good way to fix this short of modifying the other guy's code to remove the call to createInsecureRfcommSocketToServiceRecord and always call createRfcommSocketToServiceRecord? -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en