1

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.

KungFu_Panda
  • 111
  • 11
  • 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 Answers1

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

Community
  • 1
  • 1
Emil
  • 2,786
  • 20
  • 24