开发者可以访问联系人名单,以确定IM联系人中任一用户的状态,以及监视状态更新,联系人增减和处理订阅请求。

 

访问IM联系人名单

 

联系人名单需要通过本地的Content Provider,使用android.provider.Im.Contacts辅助类来访问。你可以像查询其它Content Provider一样来查询它。

 

在接下来的片段里,你可以看到如何枚举名单来得到每个IM联系人的状态:

 

Uri uri = android.provider.Im.Contacts.CONTENT_URI_CHAT_CONTACTS;

Cursor c = managedQuery(uri, null, null, null);

if (c.moveToFirst())

{

do

{

String username = c.getString(c.getColumnIndexOrThrow(Contacts.USERNAME));

int presence = c.getInt(c.getColumnIndexOrThrow(Contacts.PRESENCE_STATUS));

if (presence == Contacts.AVAILABLE) {

// TODO: Do something

}

} while (c.moveToNext());

}

相关文章:

  • 2021-11-20
  • 2022-12-23
  • 2021-08-15
  • 2021-12-10
  • 2021-11-04
  • 2021-10-02
  • 2022-12-23
猜你喜欢
  • 2021-07-30
  • 2022-12-23
  • 2021-09-11
  • 2022-12-23
  • 2021-06-12
  • 2022-02-09
  • 2021-07-18
相关资源
相似解决方案