栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

android-make whatsapp调用

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

android-make whatsapp调用

一个简单的解决方法是,查询ContactContract.Data的_id和MIME类型。

ContentResolver resolver = context.getContentResolver();  cursor = resolver.query( ContactsContract.Data.CONTENT_URI, null, null, null, ContactsContract.Contacts.DISPLAY_NAME);//Now read data from cursor likewhile (cursor.moveTonext()) {      long _id = cursor.getLong(cursor.getColumnIndex(ContactsContract.Data._ID));      String displayName = cursor.getString(cursor.getColumnIndex(ContactsContract.Data.DISPLAY_NAME));      String mimeType = cursor.getString(cursor.getColumnIndex(ContactsContract.Data.MIMETYPE));      Log.d("Data", _id+ " "+ displayName + " " + mimeType );}

输出将如下所示

12561雪vnd.android.cursor.item / vnd.com.whatsapp.profile

12562雪vnd.android.cursor.item / vnd.com.whatsapp.voip.call

现在,仅将MIME类型为_Id的内容保存在DB或其他地方

vnd.android.cursor.item/vnd.com.whatsapp.voip.call

然后像这样用这些联系人发起Whatsapp呼叫

Intent intent = new Intent();intent.setAction(Intent.ACTION_VIEW);// the _ids you save goes here at the end of /data/12562     intent.setDataAndType(Uri.parse("content://com.android.contacts/data/_id"),    "vnd.android.cursor.item/vnd.com.whatsapp.voip.call");intent.setPackage("com.whatsapp");startActivity(intent);


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/452943.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号