用AsyncTask异步的方法读取联系人列表方法:
1)在主线程的Activity下加入代码 new MyAsyncTask(this,allcontacts_cursor).execute(lv);MyAsyncTask继承自AsyncTask类,lv是ListView的对象,是传入的参数;this是当前ListActivity的Context对象;allcontacts_cursor是在当前主线程中得到的所有联系人的Cursor对象;
2)MyAsyncTask类定义如下:public class MyAsyncTask extends AsyncTask<ListView, Void, BaseAdapter>
ListView 是传入的参数,BaseAdapter是AsyncTask类中方法BaseAdapter doInBackground(ListView... params)的返回的结果,doInBackground方法的传入参数既是new MyAsyncTask(this,allcontacts_cursor).execute(lv)方法中的lv;
在方法doInBackground中主要是实例化一个adapter,并将其返回。其返回值作为方法onPostExecute(BaseAdapter result);的参数传入;
在方法onPostExecute(BaseAdapter result)中将输入参数赋值给MyAsyncTask对象的输入参数;
3)LayoutInflater的调用;
a)LayoutInflater inflater = Activity.getLayoutInflater()
b)LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
分享到:
相关推荐
NULL 博文链接:https://zymic.iteye.com/blog/737643
android的SDK做了调整,相应的读取联系人资料有了变化。 这里提供的是如何在2.0包括2.1中读取联系人资料的代码
Android-ContactsContract联系人增删改查
Android如何获取手机联系人信息,本文为大家揭晓。 获取手机联系人信息步骤: 1、获取 ContentResolver ContentResolver resolver = getContentResolver();...查询联系人邮箱的URI:ContactsContract.CommonDat
示例代码: 这是一个读取联系人的代码: 代码如下: package com.ui.domain; import java.util.ArrayList; import java.util.List; import android.app.Activity; import android.database.Cursor; import android....
//读取联系人 public static Uri CONTACTSURI = ContactsContract.Contacts.CONTENT_URI;//联系人 public static void getContactsInfo(Context context,String tag){ String[] projections = new String[]{...
这个是android系统原生代码中的联系人代码,在源代码的packages文件夹下,需要做联系人相关工作的同仁们,可以解压后看一看,同时,附赠上一个博客链接http://blog.csdn.net/Kafka_88/article/details/50670406 ...
Android 获取系统联系人信息的实例 一、获取手机联系人姓名及手机号 //跳转到系统联系人应用 Intent intent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI); try { ...
import java.util.ArrayList;import java.util.HashMap; import android.app.Activity;import android.database....import android.provider.ContactsContract.CommonDataKinds.Phone;import android.widget.ListVie
本文实例讲述了Android获取联系人头像的方法。分享给大家供大家参考,具体如下: public byte[] getPhoto(String people_id) { String photo_id = null; String selection1 = ContactsContract.Contacts._ID + = + ...
最近想写段android程序玩玩。 开发环境 eclipse ,android2.2 ...1.把通讯录中的联系人,电话号码保存到txt文件中完成备份。 2.读取txt文件,导入到通讯录完成还原。 具体代码 1.添加 通讯录读写权限,存储卡写权限 ...
本篇文档主要记录一下获取联系人的电话号码的一种方式。 1、选择联系人 ............ //构造一个隐式的Intent,拉起联系人界面 final Intent pickIntent = new Intent(Intent.ACTION_PICK, ContactsContract....
//取得联系人名字 int nameFieldColumnIndex = cursor.getColumnIndex(PhoneLookup.DISPLAY_NAME); String contact = cursor.getString(nameFieldColumnIndex); //取得电话号码 String ContactId = cursor....
ContactsContract.CommonDataKinds.Phone.NUMBER));//获取所有电话号码 String phoneTpye = phones.getString(phones.getColumnIndex( ContactsContract.CommonDataKinds.Phone.TYPE));//获取电话号码类型 ...
pickContactIntent.setType(ContactsContract.CommonDataKinds.Phone.CONTENT_TYPE); startActivityForResult(pickContactIntent, PICK_CONTACT_REQUEST); } @Override protected void onActivityResult(int ...
An application that demonstrates how to query the system contacts provider using the ContactsContract API, as well as insert contacts into a specific account. Home A home screen replacement ...
The ContactsContract and CallLog Providers The CalendarContract Provider The MediaStore Provider Consuming Documents Providing Documents Encrypted Storage Packaging and Distributing Data Advanced ...
The ContactsContract and CallLog Providers The CalendarContract Provider The MediaStore Provider Consuming Documents Providing Documents Encrypted Storage Packaging and Distributing Data Advanced ...
Introducing the ContactsContract Content Providers 322 Modifying Content Provider Data 324 Adding Records 325 Updating Records 326 Deleting Records 327 Using Third-Party Content Providers 328 Summary...