Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sending URL from Android to Windows Phone via NFC gives Play Store link

I am trying to use NFC to send a URL from an Android app to a WP8 phone.

When beaming to an Android device, the URL is sent correctly. However, when beaming to WP8, IE loads a link to the Play Store instead of the one I want to send (e.g. "http://www.stackoverflow.com").

The Play Store link is: "https://play.google.com/store/apps/details?id=com.example.conductrnfc&feature=beam". Where "com.example.conductrnfc" is the package name in the project.

The code I used to generate the NFC message is given below. Is there something I'm doing wrong here that breaks compatibility with WP8?

NfcAdapter nfc = NfcAdapter.getDefaultAdapter(this);
nfc.setNdefPushMessageCallback(new NfcAdapter.CreateNdefMessageCallback() {
    @Override
    public NdefMessage createNdefMessage(NfcEvent event)
    {
        NdefRecord uriRecord = NdefRecord.createUri(urlString);
        return new NdefMessage(new NdefRecord[] { uriRecord });
    }
}, 
this);
like image 720
J Yang Avatar asked Jan 04 '14 22:01

J Yang


1 Answers

Can you try this:

NfcAdapter nfc = NfcAdapter.getDefaultAdapter(this);
nfc.setNdefPushMessageCallback(new NfcAdapter.CreateNdefMessageCallback() {
    @Override
    public NdefMessage createNdefMessage(NfcEvent event)
    {
        byte[] payload = urlString.getBytes();
        NdefRecord uriRecord = new NdefRecord(NdefRecord.TNF_WELL_KNOWN, NdefRecord.RTD_URI, new byte[0], payload); 
        return new NdefMessage(new NdefRecord[] { uriRecord });
    }
}, 
this);
like image 192
72DFBF5B A0DF5BE9 Avatar answered Nov 08 '22 11:11

72DFBF5B A0DF5BE9