Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to beam a contact from you app (using NFC) and save it in contact list on receiving device?
    primarykey
    data
    text
    <p>How would you beam a contact using your own app (and using Android Beam) to another device and have it saved in their contact list (i.e. the default contacts app). The contact on the sending device will be provided by the <code>ContactsContract</code> provider.</p> <p>Preferably I don't want to have the other device running my app. The built-in contacts app (Android's default app) can <a href="http://youtu.be/cwU4TvQEq0g?t=83s" rel="nofollow noreferrer">beam and receive contacts</a>. So it should be possible to beam a contact using a custom app to the built-in contacts app.</p> <p>The <a href="https://stackoverflow.com/questions/13315933/how-to-build-write-a-contact-vcard-format-into-a-ndefmessage">answers to this question</a> suggest that it's possible and that you can use the VCARD format.</p> <p>Currently, my app will search for a contact by phone number, then display it in a new activity (which is the built-in contacts app). See below.</p> <pre><code>Uri uri = Uri.fromParts("tel", number.getText().toString(), ""); Log.d("ContactPicker", uri.toString()); startActivity(new Intent(ContactsContract.Intents.SHOW_OR_CREATE_CONTACT, uri)); // Example log message for the number (123)-123-1234 is "tel:(123)%20123-1234" </code></pre> <p>I'd prefer to do it this way, but don't think it's possible because I can't return the contact that was found (or the contact that was created if no existing one was found). And I need that information if I want to beam that specific contact.</p> <p>I'll probably need to query all contacts, find the contact I'm looking for and save its ID.</p> <p>Note: I'm using API 14</p> <hr> <h3>Edit</h3> <p>I made a proof of concept app that does this: <a href="https://github.com/dideler/HiFive" rel="nofollow noreferrer">https://github.com/dideler/HiFive</a> </p> <p>The app might be buggy. It's not maintained, but pull requests are welcome.</p>
    singulars
    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