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 ContactsContract
provider.
Preferably I don't want to have the other device running my app. The built-in contacts app (Android's default app) can beam and receive contacts. So it should be possible to beam a contact using a custom app to the built-in contacts app.
The answers to this question suggest that it's possible and that you can use the VCARD format.
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.
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"
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.
I'll probably need to query all contacts, find the contact I'm looking for and save its ID.
Note: I'm using API 14
I made a proof of concept app that does this: https://github.com/dideler/HiFive
The app might be buggy. It's not maintained, but pull requests are welcome.
To Transfer Individual Contacts Keep both the phones closed. Touch the both of the NFC devices together and to share the contact touch anywhere on the screen, there will be a gentle vibration to indicate that the NFC has engaged.
Stay organized with collections Save and categorize content based on your preferences. Android allows you to transfer large files between devices using the Android Beam file transfer feature. This feature has a simple API and allows users to start the transfer process by simply touching devices.
Yes, vCard is the way to go. It is the format that the built-in Contacts/People app will pick up. It is also the format that the app uses to store its own data, and I believe.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With