How to get programatically the Google import contacts in android phone.please help me.Thanks in advance
Asked
Active
Viewed 2,526 times
2 Answers
1
to get Google account information, Google provided step how to get contacts, creates new, add photo. refer this link

Mohammed Azharuddin Shaikh
- 41,633
- 14
- 96
- 115
-
you have implemented this code.First signup and other Firstname,lastname,address.Please help – Nitesh Khosla Mar 16 '12 at 05:48
-
i havnt tried, but it is successfully working as one of my friend worked on it. and further you can see @Pankaj answer for local phone contact, and remember to add permission of READ_CONTACTS. – Mohammed Azharuddin Shaikh Mar 16 '12 at 05:51
-
No I donot want local phone contacts.I want when we sign up the gmail or gooogle accounts those import contacts in google or gmail accounts. – Nitesh Khosla Mar 16 '12 at 06:07
-
you cant create/sign up programmatically see this http://stackoverflow.com/questions/2699008/can-i-create-a-google-account-programmatically – Mohammed Azharuddin Shaikh Mar 16 '12 at 06:14
-
check this http://code.google.com/apis/contacts/docs/2.0/developers_guide_java.html you will get contact list and then you can add it in your DB – Mohammed Azharuddin Shaikh Mar 16 '12 at 07:30
1
Here is a class which I tried when I was novice for Android.
public class ReadGoogleContact extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final String[] GROUP_PROJECTION = new String[] {Groups._ID, Groups.TITLE };
Cursor groupCursor = getContentResolver().query(Groups.CONTENT_URI, GROUP_PROJECTION, null, null, Groups.TITLE);
if(groupCursor.getCount() > 0) {
while(groupCursor.moveToNext()) {
String groupId = groupCursor.getString(groupCursor.getColumnIndex(Groups._ID));
String groupName = groupCursor.getString(groupCursor.getColumnIndex(Groups.TITLE));
Log.i("GoogleGroup", "Group Id : " + groupId + " Group Name : " + groupName);
printContacts(groupName, groupId);
}
} else {
Log.i("GoogleGroup", "No any group found");
}
if(groupCursor != null || !groupCursor.isClosed())
groupCursor.close();
}
private void printContacts(String groupName, String groupId) {//getGroupWiseContacts(String id) {
Cursor cursor = this.managedQuery(Data.CONTENT_URI, new String[] {
Contacts.DISPLAY_NAME, Contacts._ID },
GroupMembership.GROUP_ROW_ID + " = ?",
new String[] { groupId }, Phone.TIMES_CONTACTED + " DESC");
Log.i("GoogleGroup", "___________ " + groupName + " ________________________");
if(cursor.getCount() > 0) {
while(cursor.moveToNext()) {
Log.i("GoogleGroup", "Contact id : " + cursor.getString(1) + " Display Name : " + cursor.getString(0));
}
} else {
Log.i("GoogleGroup", "No any contacts with this group");
}
if(cursor != null || !cursor.isClosed())
cursor.close();
}
}
And more information you can refer this docs

Pankaj Kumar
- 81,967
- 29
- 167
- 186
-
-
@hotveryspicy Yes you are right. He didn't put this in his question. So should I remove my answer? – Pankaj Kumar Mar 16 '12 at 06:10
-
no, its Ok. because contacts are contacts either local or web. people will get both from here – Mohammed Azharuddin Shaikh Mar 16 '12 at 06:13