I am making an app that displays a list of people in a listview. When tapped, the app should transition to another screen displaying the contact details of that person loaded from a Person object i have retrieved from the DB. My question is how to display these details. In iOS, there was a ABUnknownPersonViewController that would mimic the native iOS addressbook entry to let me display the contact details in a clean and easy way. Is there anything similar for android that would let me use the People app's view or api to basically create and display a record exactly as android displays in its own People app?
your exact answer is contained here:
Open Contacts
The method described in the above link opens native contacts app and lets the user pick a contact. Then onActivityResult() comes into picture, here you can process the contact as per your requirement.
If you want to customize the look and feel you need to check here
You can retrieve the list and customize the UI.
If you just want to display a single contact's details. you can use this code. (contactId is the contactId of the contact that user picked)
Intent contactIntent = new Intent(Intent.ACTION_VIEW);
Uri uri = Uri.withAppendedPath(
ContactsContract.Contacts.CONTENT_URI,
String.valueOf(contactId));
contactIntent.setData(uri);
startActivity(contactIntent);
Hope this helps.
No. You can look through the AOSP and see if the contacts app was released as open source, and if so use it. But remember that the contact app on all phones isn't the same, Samsung for example uses several different apps of their own. And some people download their own contact apps. So its impossible to have the native feel for everyone, unless you launch the contact app via an intent.
Related
WhatsApp recently added the call feature. Before this, there was only one option when viewing a contact, that was to message the contact. Now there is the option to message or call a contact. Did WhatsApp add this entry to the ContactsContract, or did Google modify the contacts app to cater for WhatsApp? I am trying to make a custom contacts app, but I don't understand how to create links to apps from within this custom contacts app.
I have read this question,
How to get contacts which are used in whatsapp or other application in android
But the solution isn't generic enough. I want to make a contacts app that doesn't have the names of applications hard coded in.
An Android app can advertise in it's manifest it handles implicit intent for a given action (see Receiving an implicit intent). In this case, a dial action.
And to your practical question - you can use the PackageManager to query which Activities can handle an intent (in this case, an intent with ACTION_DIAL action), and use the PackageManager to get their name, icon, etc.
In WhatsApp case, you would like to know which contacts are WhatsApp users, but WhatsApp does not have an API or it's own ContentProvider. This 2014 blog post solution might be still valid, haven't checked.
Every app can only specify what type of uri scheme they can handle like sms:// or tel:// . For clearification, Apps cann't add entry of itself in some other apps.
In your Example case:
The Contact app itself implemented in such a way that it list all apps which can handle sms:// or tel:// type of uri scheme.
As the older version of WhatsApp can only handle sms:// uri scheme that's why Contact app only list SMS/message option. Also with calling feature in WhatsApp they added support for handling tel:// uri scheme that's why Contact app also shows the calling option.
It's possible to have a button in my web page, for sending pre-filled messages to specific number?
i'm trying with
intent://send/+391234567890#Intent;scheme=smsto;package=com.whatsapp;action=android.intent.action.SENDTO;end;whatsapp://send?text=
nothing result.
have a solution? Thanks
Firstly, write the country code without +
Message me in WhatsApp
Sadly this does not work unless the number is already in your contacts list! Making it useless.
Here's what happens for me: I get a modal dialog saying the user is not on WhatsApp and I can either Invite or SMS. This is a mistake - they're DEFINITELY on WhatsApp, but not in my contacts because I've deleted them for testing.
Workaround idea
Offer vCard to save to Contacts
Since the phone number has to be in the Contacts list first, let's get it there. Track the site visitor to see if it's the first time she tapped on Contact me on WhatsApp (a cookie?). If it's the first time she tapped, make the link download your vCard
href="johnsmith.vcf"
The user now has to open the downloaded vCard with the People app, and add you to her Contacts.
Android intents URI FTW
When she returns, assuming she added you, make the button work with the intent:// URI scheme.
href="intent://send/391234567890#Intent;scheme=smsto;package=com.whatsapp;action=android.intent.action.SENDTO;end"
She taps on it and is magically transported to a WhatsApp chat with you.
Keep track of which href to present
Hopefully you can use the cookie you set to track her so you don't have the button offer the vCard AGAIN. There's no other way to know if your number is in her Contacts list unless you ask. But then it's not a button anymore, it's a form.
Same goes for Telegram. Security implications are probably the ones keeping Instant Messaging not so instant.
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
Edit
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.
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.
I have a contact picker in my application that keeps crashing when a facebook contact is selected. I won't have the code I'm using to open the picker in front of me, but I believe I'm accessing the contacts through a call similar to this:
new Intent(Intent.ACTION_PICK, People.CONTENT_URI)
Does anyone have experience with this?
i wish i had an answer for you but i posted 2 similar questions without any good answers. seems like a totally reasonable question and easy to do in most other dev environments (im actually a c# developer) but android has got me stuck on this. i think i may just have to write my "own contact picker" so that i can test for the fact that the contact has a number before adding them to the picker list programmatically.
anyways, my questions are here:
How do get the android sdk contact picker to give me just phone results and not all my twitter followers
how do i get startActivityForResult() to bring up just a list of telephone contacts (like when i click on the "People" icon) using the android sdk?
in my app i am testing that the phone gets returned from the picked contact before trying to send it a message (so mine doesnt crash), but i dont want the user to have to see a "that contact doesnt have a number" message if they dont have to.
i found this too:
http://mobile.dzone.com/news/contacts-api-20-and-above
while it DOESNT show you how to filter the contact list, it does show how to programmatically create a list that has only contacts with numbers. write back on my questions if you find anything that could be useful, thanks!
I am trying to add these functionality in my Android app:
1) Get A list of suggested contacts from a Web Service and Display them in a list view
- This I have implemented and working fine
2) When User selects any of these contacts I want to present them in Native Contact View. My fried who is iPhone developer was able to do this with help of ABPerson class which provides feature to display the contact in native contact view page without adding the contact to contact list. I am not able to find any such API in Andoid. Please suggest.
3) When User want to edit any contact in the above list, I am able to present Edit Contact activity from native Phone Book app. This is working fine, but I am not able to remove the Done and Revert button. Unfortunately due to this, if user click on Done that contact is added to phone, however, what I want to do here is that, user can modify the data and I will keep it in the memory till the export process starts. During the export process I will insert these records in the Phone Book.
Please suggest me how can I do this.
I would advise you look over the BusinessCard sample and ContactManager sample posted on the Android developer site.
Reading carefully through both of these is what helped me understand exactly what's going on in the contacts API.