Finding account nature of a contact group?

后端 未结 2 1067
一个人的身影
一个人的身影 2021-01-06 05:14

I am developing an application in which it is required to find the nature of a contact group means whether it is google group , phone group or sim group. How to find it.Plea

2条回答
  •  -上瘾入骨i
    2021-01-06 05:46

    I have same problem which you have mentioned i solved it like this way

    ArrayList stateList = new ArrayList();
          final String[] GROUP_PROJECTION = new String[] 
                    {
                        ContactsContract.Groups._ID, ContactsContract.Groups.TITLE,   ContactsContract.Groups.ACCOUNT_TYPE//this line will do the trick
                    };
                Cursor cursor = getContentResolver().query(ContactsContract.Groups.CONTENT_URI, GROUP_PROJECTION, null,
                        null, ContactsContract.Groups.TITLE);
                while (cursor.moveToNext()) {
                    String accountname=cursor.getString(cursor.getColumnIndex(ContactsContract.Groups.ACCOUNT_TYPE));
                    Toast.makeText(getBaseContext(), accountname, Toast.LENGTH_LONG).show();// and it will display group type
                    String id = cursor.getString(cursor.getColumnIndex(ContactsContract.Groups._ID));
                    Log.v("Test", id);
                    //ContactsContract.Groups.ACCOUNT_NAME
    
                    String gTitle = (cursor.getString(cursor.getColumnIndex(ContactsContract.Groups.TITLE)));
                    if(favGroupName.contains(gTitle)==false)
                    {
                    favGroupId.add(id);
                    favGroupName.add(gTitle);
    
                    GroupNameDetails _states = new GroupNameDetails(Long.parseLong(id),gTitle, false);
                    stateList.add(_states);
                    }
                    Log.v("Test", gTitle);
                    if (gTitle.contains("Favorite_")) {
                        gTitle = "Favorites";
    
                    }
    
                }
    

提交回复
热议问题