1

I am working with android beam to send data using NFC between two different apps, I have tested code from different answer, I have changed parameters, etc., and I always obtain the same result: The other device open or try to open the same app in the other device. I need to open a different app. Can someone help me??

1) Sender application

public NdefMessage createNdefMessage(NfcEvent event) {

    SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
    String currentDate= sdf.format(new Date());


    NdefMessage msg = new NdefMessage(NdefRecord.createMime("application/com.myapp", currentDate.getBytes()) );
    return msg;
}

2) The application that receives

<intent-filter>
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
    <action android:name="android.nfc.action.NDEF_DISCOVERED"/>
    <category android:name="android.intent.category.DEFAULT"/>
    <data android:mimeType="application/com.myapp" />
</intent-filter>
Michael Roland
  • 39,663
  • 10
  • 99
  • 206
impilar
  • 11
  • 5
  • Have you checked [this question](http://stackoverflow.com/q/27062261/2425802)? This question seems to describe that Android Beam has some unexpected behavior on certain Samsung devices (i.e. that an AAR is sent instead of the custom NDEF message). So your devices might be affected as well... – Michael Roland Dec 17 '14 at 23:26
  • First of all, thanks for your reply Michael. I work with the Nexus 5 and Samsung S5. The problem I've encountered, seems more related to the sending of messages between different application than between different devices. Because if I include all the code in one and install this app in both phones, it works perfectly. The problem is when I use two different applications, one for send information and another to read it . – impilar Dec 19 '14 at 08:00
  • I have tried some other solutions that you have proposed in response to other posts on the forum. The result was always the same, I can not send information between two different applications using NFC. – impilar Dec 19 '14 at 08:01
  • What I wanted to point out was that certain Samsung devices always send an AAR (which may cause exactly what you are experiencing). So could you provide some more clarification: Does this happen for both directions? (I.e. does it make a difference if the Nexus 5 or the S5 is the sender?) On which device will "the same app" be opened? (I.e. will the sender app be opened on the receiver device or will the receiver app be opened on the sender device?) – Michael Roland Dec 19 '14 at 10:17
  • Yes, the result is the same whether the sender is the S5 or Nexus 5. The device that receive the information try to open the application that are using the device that sends data. – impilar Dec 19 '14 at 11:31
  • How are you registering to send the NDEF message on the sender side? Is "application/com.myapp" the actual MIME type that you are trying to use? – Michael Roland Dec 19 '14 at 14:40

0 Answers0