Note that there are some explanatory texts on larger screens.

plurals
  1. POAccess Android's OBEX server and read data
    primarykey
    data
    text
    <p>I was wondering if it's possible to read data (contacts, missed calls, etc.) from Android's OBEX server from windows with Bluecove. I tried the following code from windows, but it returns <code>OBEX_HTTP_NOT_ACCEPTABLE</code> when connecting. Device address and channel are correct as I can tell since when running this test, android pops up a dialog asking if I allow the other device to access it's contacs. Thanks!</p> <p>code:</p> <pre><code>import java.io.IOException; import javax.microedition.io.Connector; import javax.obex.*; public class PBAPTest1 { public static void main(String[] args) { String deviceAddress = "001122334455"; int channel = 19; String serverURL = "btgoep://" + deviceAddress + ":" + channel + ";authenticate=false;encrypt=false;master=false"; System.out.println("Connecting to " + serverURL); ClientSession clientSession = null; Operation op = null; HeaderSet hdr = null; try { clientSession = (ClientSession) Connector.open(serverURL); hdr = clientSession.connect(clientSession.createHeaderSet()); if (hdr.getResponseCode() != ResponseCodes.OBEX_HTTP_OK) { System.out.println("Failed to connect: " + hdr.getResponseCode()); // response: 198 OBEX_HTTP_NOT_ACCEPTABLE return; } } catch (IOException e) { e.printStackTrace(); return; } byte[] PBAP_TARGET = new byte[] { 0x79, 0x61, 0x35, (byte) 0xf0, (byte) 0xf0, (byte) 0xc5, 0x11, (byte) 0xd8, 0x09, 0x66, 0x08, 0x00, 0x20, 0x0c, (byte) 0x9a, 0x66 }; hdr.setHeader(HeaderSet.TARGET, PBAP_TARGET); hdr.setHeader(HeaderSet.NAME, "pb.vcf"); hdr.setHeader(HeaderSet.TYPE, "x-bt/vcard-listing"); try { op = clientSession.get(hdr); } catch (IOException e) { e.printStackTrace(); } } } </code></pre> <p>logcat:</p> <pre><code>D/BluetoothEventLoop( 1551): Device property changed: XX:XX:XX:XX:XX:XX property: Connected value: true D/BluetoothService( 1551): CONNECTION_STATE_CHANGE: XX:XX:XX:XX:XX:XX: 0 -&gt; 2 D/Obex ServerSession( 1948): java.io.IOException: Software caused connection abort D/BluetoothAdapterStateMachine( 1551): BluetoothOn process message: 52 D/BluetoothService( 1551): CONNECTION_STATE_CHANGE: XX:XX:XX:XX:XX:XX: 2 -&gt; 0 D/BluetoothEventLoop( 1551): Device property changed: XX:XX:XX:XX:XX:XX property: Connected value: false </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload