मैं अपने आप createBond() कॉल, android.bluetooth के लिए एक प्रसारण रिसीवर पंजीकरण से एक ब्लूटूथ डिवाइस के साथ युग्मित करने के लिए कुछ कोड है में काम करता है। device.action.PAIRING_REQUEST और उसके बाद मैन्युअल रूप से पिन कोड दर्ज करना।Android.bluetooth.IBluetooth.createBond() 4.2.1 में नहीं मिला लेकिन पहले OS संस्करण
java.lang.noSuchMethodException: एंड्रॉयड
यह अब तक 4.0 Andoid अप करने के लिए लेकिन आज मैं एंड्रॉयड 4.2.1 के साथ अपने Nexus 7 पर इस कोशिश की और निम्न त्रुटि मिल गया परीक्षण किया सभी उपकरणों के साथ महान काम किया है। bluetooth.IBluetooth.createBond
वे वास्तव में लाइब्रेरी से यह समारोह को दूर किया?
अद्यतन
क्या वास्तव में हो रहा है IBluetooth इंटरफ़ेस उद्देश्य यह है कि मैं फोन करने के लिए createBond आरंभ नहीं किया जा रहा है का उपयोग कर रहा है। निम्नलिखित कोड में लाइन IBinder BTBinder नामित निकलने की कोशिश करता है कि रिक्त लौटाता है जब इस प्रक्रिया BTInterface के कारण अंत में अशक्त करने के लिए स्थापित किया जाना विफल रहता है। तो, मेरा सवाल यह है कि एंड्रॉइड 4.2.1 के साथ मेरे नेक्सस 7 पर बाइंडर रिटर्न शून्य पाने के लिए कॉल क्यों है, लेकिन मैंने परीक्षण किए गए 5 अन्य उपकरणों पर सही तरीके से काम किया है?
public static IBluetooth getBluetoothInterface()
{
//Gets a bluetooth interface from private Android system API
IBluetooth BTInterface = null;
try
{
Class<?> ServiceManager = Class.forName("android.os.ServiceManager");
Method getService = ServiceManager.getDeclaredMethod("getService", String.class);
IBinder BTBinder = (IBinder) getService.invoke(null, "bluetooth");
Class<?> IBluetooth = Class.forName("android.bluetooth.IBluetooth");
Class<?>[] IBluetoothClasses = IBluetooth.getDeclaredClasses();
Class<?> IBluetoothClass0 = IBluetoothClasses[0];
Method asInterface = IBluetoothClass0.getDeclaredMethod("asInterface",IBinder.class);
asInterface.setAccessible(true);
BTInterface = (IBluetooth) asInterface.invoke(null, BTBinder);
}
catch (Exception e)
{
return null;
}
return BTInterface;
}
मैं बहुत tuis समस्या में दिलचस्पी रहा हूँ। यदि आपके पास कुछ खबर है, तो कृपया उन्हें साझा करें: पी। – castrogne