2011-11-15 30 views
0
public class TestConnection extends Activity { 
/** Called when the activity is first created. */ 
public static final UUID BluetoothSerialUuid = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB"); 
private BluetoothAdapter _adapter; 
BluetoothSocket socket=null; 

@Override 
protected void onPause() { 
    try { 
     socket.close(); 
    } catch (IOException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    } 
}; 

@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.main); 
    TextView text = (TextView) findViewById(R.id.mainText); 
    text.setText("This is a test"); 

    String deviceAddress = "05:03:e8:c0:bf:c0"; 
    _adapter = BluetoothAdapter.getDefaultAdapter(); 

    BluetoothDevice device = _adapter.getRemoteDevice(deviceAddress); 

    try { 
     socket = device.createRfcommSocketToServiceRecord(BluetoothSerialUuid); 
    } catch (IOException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    } 

    try { 
     socket.connect(); 
    } catch (IOException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    } 

} 

}アンドロイドにBluetooth SPPを接続する際の問題?

私はこのサイトからいくつかのコードを使用しようとしています:

http://zornsoftware.talsit.info/blog/pairing-spp-bluetooth-devices-with-android-phones.html

が実際アンドロイドスキップクラス0x00のBluetoothデバイスを克服します。しかし、私がこれを行うとき: _adapter.getRemoteDevice(deviceAddress);

私は、これが失敗した理由は、今のマニフェストファイルに正しい権限を有することに起因することに気づいた応答

答えて

0

を取得することはありません。

関連する問題