`
zymic
  • 浏览: 24160 次
  • 性别: Icon_minigender_1
  • 来自: 合肥
文章分类
社区版块
存档分类
最新评论

ContactsContract读取联系人的异步方法

 
阅读更多

用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);

0
0
分享到:
评论

相关推荐

    android中ContactsContract获取联系人的方法

    NULL 博文链接:https://zymic.iteye.com/blog/737643

    Android2.0 中读取联系人——ContactsContract

    android的SDK做了调整,相应的读取联系人资料有了变化。 这里提供的是如何在2.0包括2.1中读取联系人资料的代码

    Android-ContactsContract联系人增删改查

    Android-ContactsContract联系人增删改查

    Android获取手机联系人信息

    Android如何获取手机联系人信息,本文为大家揭晓。 获取手机联系人信息步骤: 1、获取 ContentResolver ContentResolver resolver = getContentResolver();...查询联系人邮箱的URI:ContactsContract.CommonDat

    Android控件ListView用法(读取联系人示例代码)

    示例代码: 这是一个读取联系人的代码: 代码如下: package com.ui.domain; import java.util.ArrayList; import java.util.List; import android.app.Activity; import android.database.Cursor; import android....

    android实现读取、搜索联系人的代码

    //读取联系人 public static Uri CONTACTSURI = ContactsContract.Contacts.CONTENT_URI;//联系人  public static void getContactsInfo(Context context,String tag){  String[] projections = new String[]{...

    手机联系人android原生代码

    这个是android系统原生代码中的联系人代码,在源代码的packages文件夹下,需要做联系人相关工作的同仁们,可以解压后看一看,同时,附赠上一个博客链接http://blog.csdn.net/Kafka_88/article/details/50670406 ...

    Android获取手机联系人的方法

    Android 获取系统联系人信息的实例 一、获取手机联系人姓名及手机号 //跳转到系统联系人应用 Intent intent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI); try { ...

    android获取联系人示例分享

    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获取联系人头像的方法

    本文实例讲述了Android获取联系人头像的方法。分享给大家供大家参考,具体如下: public byte[] getPhoto(String people_id) { String photo_id = null; String selection1 = ContactsContract.Contacts._ID + = + ...

    android手机通讯录备份还原代码

    最近想写段android程序玩玩。 开发环境 eclipse ,android2.2 ...1.把通讯录中的联系人,电话号码保存到txt文件中完成备份。 2.读取txt文件,导入到通讯录完成还原。 具体代码 1.添加 通讯录读写权限,存储卡写权限 ...

    Android实现获取联系人电话号码功能

    本篇文档主要记录一下获取联系人的电话号码的一种方式。 1、选择联系人 ............ //构造一个隐式的Intent,拉起联系人界面 final Intent pickIntent = new Intent(Intent.ACTION_PICK, ContactsContract....

    package com.example.f1_telephone;

    //取得联系人名字 int nameFieldColumnIndex = cursor.getColumnIndex(PhoneLookup.DISPLAY_NAME); String contact = cursor.getString(nameFieldColumnIndex); //取得电话号码 String ContactId = cursor....

    Android 向所有用户的手机发送短信.rar

     ContactsContract.CommonDataKinds.Phone.NUMBER));//获取所有电话号码  String phoneTpye = phones.getString(phones.getColumnIndex(  ContactsContract.CommonDataKinds.Phone.TYPE));//获取电话号码类型 ...

    Android代码-一个onActivityForResult handlers的方便注解

    pickContactIntent.setType(ContactsContract.CommonDataKinds.Phone.CONTENT_TYPE); startActivityForResult(pickContactIntent, PICK_CONTACT_REQUEST); } @Override protected void onActivityResult(int ...

    android sdk 自带 实例(samples)

    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 Busy Coders Guide to Android Development最终版2019

    The ContactsContract and CallLog Providers The CalendarContract Provider The MediaStore Provider Consuming Documents Providing Documents Encrypted Storage Packaging and Distributing Data Advanced ...

    CommonsWare.The.Busy.Coders.Guide.to.Android.Development.Version.8.2.2017

    The ContactsContract and CallLog Providers The CalendarContract Provider The MediaStore Provider Consuming Documents Providing Documents Encrypted Storage Packaging and Distributing Data Advanced ...

    Introduction.to.Android.Application.Development(4th,2013.12) pdf

    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...

Global site tag (gtag.js) - Google Analytics