I'm writing a custom Android contacts directory, I have implemented the ContactsContract.Directory provider and the search from within the phone app works fine.
The problem I am facing now is that when I have an incoming/outgoing call the Android dialer does not query the custom directory I registered. Is it possible to partake in caller ID resolution via PhoneLookup or some other way?
Also as a possible workaround I have tried implementing an outgoing/incoming call interceptor with BroadcastReceiver but I see no way of returning the contact data to the dialer. The only option I have found for displaying the data is to overlay a transparent activity over the native dialer. Is there a way to return contact data back to the dialer that sent the broadcast? Any other ideas I could try?
PS. Google uses the functionality I'm trying to implement for nearby places directory listings and Caller ID by Google.
PPS. By reading the ContactsContract implementation of PhoneLookup I stumbled upon corporate contacts directory that can be appended to the user profile's default directory, according to the code it should get queried for PhoneLookup, so I'm going to try that on Monday.
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.
I'm currently writing an App which allows to extend the standart Android contacts / phonebook. The user can add some informations / content associated with a specific contact. I want the standart phonebook to show an link to my application on every contact which has additional data in my application. For example WhatsApp is able to do so. If somebody from you phonebook has an WhatsApp account the phonebook displays a small WhatsApp icon next to the contact. If you hit the icon WhatsApp starts automatically a chat with this specific person.
My question is now how this can be achieved ? If someone can point me in the right direction it would be great.
I guess it must be done somehow with an ContentProvider. I already specified an ContentProvider but I don't know how to tell the Contacts app that this one exist or where I need to register this provider.
You need to use Contacts Provider. Class ContactsContract.Contacts provide access to all the contacts available in android mobile.
You need to have Read contacts permission in your app manifest.
<uses-permission android:name="android.permission.READ_CONTACTS" />
Refer following Android developer site.
http://developer.android.com/training/contacts-provider/index.html
Source code can be downloaded at http://developer.android.com/shareables/training/ContactsList.zip
I'm developing an app and one thing I would like to do it allow users to send/share data from the app with others vi MMS or by email. I have been searching but haven't found anywhere to get started on solving the problem.
Basically, I am going to programatically draw the data from an SQLite DB and put it into a delimited file (similar to a .csv) then I want to allow the user to 'export' or send it via MMS or Email. Does anyone have any tips on how I can get my program to open the messaging application and add the attachment at the users direction? Really just need some beginning info so I have a place to start.
Here is what you are looking for. This should be a good start
launch sms application with an intent
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 want to let my app scan the users contactlist , and display the name of the contacts who also installed the app.
I have no idea where to begin with this . so if someone could help me getting started , that would be apreciated.
grtz
You will need to research ContentResolver because you will have to query the database containing the contacts. To do these queries, you will need the URI and column/header names for contacts db which can be found in the Contacts class.
You will also need users to register that they have your app on your own servers and the registration will need a piece of information about the user that other users would have in their contacts (the users phone number, email address, etc).
You will then need to query a few users at a time from the users contacts for this piece of information (using the ContentResolver and Contacts class), pass it to your server (as text) where it will check if they are registered, then send a message back to initial user (and possibly the match) that you found a match.
That's where you should start, and end :)
Note, you will need these permissions in the Manifest file:
android.permission.INTERNET
android.permission.READ_CONTACTS
First of all, welcome to StackOverflow. StackOverflow is for programming questions. As is such, a post asking for help should always provide a description of what you have already tried. If you haven't tried anything yet, I highly encourage you to try something, and post when you encounter a problem.
As your question stands now, we don't know what the problem is. Are you having problems scanning a contact list? Or are you having problems trying to figure out if another user has installed the app?
That being said, you will have to maintain a database for your app containing a list of people who have installed your app. When your app is launched on one device, do whatever you need to do to register the user in your database. Due to the nature of a "contact," one person's phone may only have their phone number, email address, or even just a name. This is of course something you will have to deal with in your implementation.