2012-11-01 3 views
8

며칠 전에 Google Play 스토어에 블루투스 스마트 스캐너 소프트웨어를 다운로드했습니다. 삼성 Galaxy S3 휴대 전화에 설치 한 후 Bluetooth LE 장치를 성공적으로 검색 할 수있었습니다.삼성 갤럭시 S3를 사용하여 BluetoothLE 장치에 연결

내 블루투스 LE 장치를 검색하는 데 모든 방법을 시도했지만 컴퓨터에 아무 것도 표시되지 않았습니다. 이렇게 나는이 소프트웨어를 decompiled, 포장에서 startLeDiscovery() 방법이 있었다 android.bluetooth. 그러나 혼란 뭔지는이 방법이 마침내 안드로이드 SDK (15)

android.jar에 존재하지 않았던 것이 었습니다, 나는 BlutoothAdapter.class 파일 및 블루투스 스마트 스캐너 소프트웨어의 그들과 android.jarBluetoothDevice.class 파일을 대체 내가 성공적으로 할 수 있도록 Eclipse에서 startLeDiscovery() 메소드를 호출하십시오. 소스 코드는 아래와 같습니다.

public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_main); 

    IntentFilter intent = new IntentFilter(); 
    intent.addAction(BluetoothDevice.ACTION_FOUND); 
    intent.addAction(BluetoothDevice.EXTRA_UUID); 
    intent.addAction(BluetoothDevice.ACTION_GATT_PRIMARY_UUID); 

    registerReceiver(searchDevices, intent); 
    //bluetooth.discovery();  
    bluetooth.startLeDiscovery(); 

    } 
    private BroadcastReceiver searchDevices = new BroadcastReceiver() { 
    public void onReceive(Context context, Intent intent) { 
     String action = intent.getAction(); 
     BluetoothDevice device = null; 

     if (BluetoothDevice.ACTION_FOUND.equals(action)) { 
      device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); 
      String msg = device.getName()+"\n"+device.getAddress(); 
      Log.i("hella",msg); 
      bluetooth.cancelDiscovery(); 
      connectDevice(device); 
     } 
    }  
};` 

나는 갤럭시 S3 휴대 전화에서 내 블루투스 LE 장치를 성공적으로 스캔 한 것으로 나타났습니다. 그렇지 않으면 com.samsung.bluetoothle 패키지가 있다는 것을 발견했습니다. 같은 방식으로, 나는 그것을 내 android.jar에 추가했습니다. 하지만 그 패키지에있는 방법을 사용하여 LE 장치에 연결할 수 없습니다.

나는 오랫동안 우리를 괴롭 히고있는이 문제를 해결하기 위해 친절하게 도움을 요청합니다. 개발을 용이하게하기 위해 웹 사이트에 android.jar을 기고합니다. startLeDiscovery() 방법 및 기타 방법은 android.bluetooth 디렉토리에 표시됩니다. 물론, android 디렉토리에 com.samsung.bluetoothle 패키지도 있습니다.

android.jar 패키지 here (Mirror)을 다운로드 할 수 있습니다.

답변

0

android.jar 파일은 안드로이드 장치에 이미있는 클래스로 간주됩니다 : 난 그렇게하지 않습니다 android.jarcom.samsung.bluetoothle 클래스를 추가, 제대로 그 클래스가 앱 생성되는 APK에 포함되지 않은 기억을 되살려 앱에 추가됩니다.

android.jar 파일을 디 컴파일하여 추가하는 대신 삼성 웹 사이트 (http://developer.samsung.com/ble)에서 전체 SDK를 다운로드하고 권장되는 방식으로 사용하는 것이 가장 좋은 이유는 무엇입니까?

0

Galaxy S3 블루투스 라이브러리를 사용하도록 앱에 알리려면 AndroidManifest.xml에 uses-library 태그가 있어야합니다. Samsung은 공개적으로 개발자 용 라이브러리를 공개하지 않았으므로 컴파일 할 jar 파일을 만들어야하지만 apk 패키징에 jar 파일을 포함시키지 마십시오.

<uses-library android:name="com.samsung.bluetoothle.BluetoothLEClientProfile" android:required="false" /> 

당신이 필요로하는 방법에 대한 참조를 얻고 그 방법을 호출 반사를 사용하여 떨어져 당신이 최고 BluetoothAdapter 및 BluetoothDevice의 방법에 액세스 할 수 있습니다.

관련 문제