找到一个联络小组的账户性质是什么? [英] Finding account nature of a contact group?

查看:175
本文介绍了找到一个联络小组的账户性质是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发的,它需要找到一个联络小组的性质意味着无论是谷歌集团,集团电话或SIM组的应用程序。如何找到it.Please建议我该怎么做。 先谢谢了。

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.Please suggest me how to do it. Thanks in advance.

推荐答案

在code以下打印联系人姓名和类型。我没有优化它,它会打印多条记录,但我想你会知道该怎么做。

The code below prints the contact name and type. I have not optimized it and it will print multiple records but I think you will know what to do.

package com.example.android.contactmanager;
import android.app.Activity;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.provider.ContactsContract;
import android.provider.ContactsContract.RawContacts;
import android.util.Log;

public final class ContactManager extends Activity{

/**
 * Called when the activity is first created. Responsible for initializing the UI.
 */
@Override
public void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    printContactList();
}

/**
 * Print contact data in logcat.
 * SIM : Account_Type = com.anddroid.contacts.sim
 * Phone : Depends on the manufacturer e.g For HTC : Account_Type = com.htc.android.pcsc
 * Google : Account_Type = com.google
 */
private void printContactList() {
    Cursor cursor = getContacts();
    cursor.moveToFirst();
    while (cursor.isAfterLast() == false) {
        Log.d("Display_Name", cursor.getString(cursor.getColumnIndex(ContactsContract.Data.DISPLAY_NAME)));
        Log.d("Account_Type", cursor.getString(cursor.getColumnIndex(RawContacts.ACCOUNT_TYPE)));
        cursor.moveToNext();

    }
}

/**
 * Obtains the contact list for the currently selected account.
 *
 * @return A cursor for for accessing the contact list.
 */
private Cursor getContacts()
{
    // Run query
    Uri uri = ContactsContract.Data.CONTENT_URI;
    String[] projection = new String[] {
            ContactsContract.Contacts._ID,
            ContactsContract.Contacts.DISPLAY_NAME,
            RawContacts.ACCOUNT_TYPE
    };
    String[] selectionArgs = null;
    String sortOrder = ContactsContract.Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC";

    return managedQuery(uri, projection, null, selectionArgs, sortOrder);
}
}

这篇关于找到一个联络小组的账户性质是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆