I am trying to implement signup activity in android using phone number as done by whatsapp and many other applications these days. But i also need to know the name of the user but without prompting the user to enter it himself/herself. is it possible? how does whatsApp manages to do it? Looking for any suggestions possible here. Thanks.
Asked
Active
Viewed 190 times
1
-
Please look at these two posts: [This](http://stackoverflow.com/questions/2727029/how-can-i-get-the-google-username-on-android) and [this one](http://stackoverflow.com/questions/2727029/how-can-i-get-the-google-username-on-android) – NightFury Aug 24 '15 at 05:00
1 Answers
1
You can use ContactsContract.Profile
String name = "";
Cursor c = getApplication().getContentResolver().query(ContactsContract.Profile.CONTENT_URI, null, null, null, null);
if(c.moveToFirst()) {
name = c.getString(c.getColumnIndex("display_name"));
c.close();
}
You need permissions too
<uses-permission android:name="android.permission.READ_PROFILE"/>
<uses-permission android:name="android.permission.READ_CONTACTS"/>
Read this Get Owner Name of an Android Device
-
-
Read this for more info http://developer.android.com/reference/android/provider/ContactsContract.Profile.html – Emil Aug 24 '15 at 05:03