我怎样才能打开使用联系人数据的WhatsApp的谈话活动? [英] How can I open WhatsApp's conversation activity using contact data?

查看:161
本文介绍了我怎样才能打开使用联系人数据的WhatsApp的谈话活动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想开什么,从我的应用程序的应用程序会话活动 CMP = com.whatsapp / .Conversation

我怎样才能做到这一点?我的联系电话,联系人身份证,接触生的id,也有什么应用程序的URI为一个特定的联系人。

 私人无效openWhatsApp(字符串ID){

    意图I =新的意图(Intent.ACTION_VIEW,Uri.parse(内容://com.android.contacts/data/+ ID));
    Log.v(SSSSSS,多个);
    i.setType(vnd.android.cursor.item / vnd.com.whatsapp.profile);
    i.setComponent(新单元名(com.whatsapp,.Conversation));
    startActivity(ⅰ);
}


04-20 18:13:45.794:I / ActivityManager(1862年):启动
{行动= android.intent.action.VIEW
DAT =内容://com.android.contacts/data/8269
(典型值)= vnd.android.cursor.item / vnd.com.whatsapp.profile
CMP = com.whatsapp /从PID 32159 .accountsync.ProfileActivity}


04-20 18:42:11.317:I / ActivityManager(1862年):开始从PID 1150 {FLG = 0x14000000 CMP = com.whatsapp / .Conversation(有群众演员)}
 

解决方案

 私人无效openWhatsApp(字符串ID){

光标C = getSherlockActivity()。getContentResolver()查询(ContactsContract.Data.CONTENT_URI,
        新的String [] {} ContactsContract.Contacts.Data._ID,ContactsContract.Data.DATA1 +=?,
        新的String [] {ID},NULL);
c.moveToFirst();
意图I =新的意图(Intent.ACTION_VIEW,Uri.parse(内容://com.android.contacts/data/+ c.getString(0)));

startActivity(ⅰ);
c.close();
}
 

其中id是什么样的应用程序的URI像 0987654321@s.whatsapp.net

I want open what's app conversation activity cmp=com.whatsapp/.Conversation from my app.

How can I do this? I have contact phone number, contact id, contact raw id and also have what's app uri for a particular contact.

private void openWhatsApp(String id) {

    Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("content://com.android.contacts/data/"+id));
    Log.v("ssssss", s);
    i.setType("vnd.android.cursor.item/vnd.com.whatsapp.profile");
    i.setComponent(new ComponentName("com.whatsapp", ".Conversation"));
    startActivity(i);
}


04-20 18:13:45.794: I/ActivityManager(1862): START
{act=android.intent.action.VIEW
dat=content://com.android.contacts/data/8269
typ=vnd.android.cursor.item/vnd.com.whatsapp.profile
cmp=com.whatsapp/.accountsync.ProfileActivity} from pid 32159


04-20 18:42:11.317: I/ActivityManager(1862): START {flg=0x14000000 cmp=com.whatsapp/.Conversation (has extras)} from pid 1150

解决方案

private void openWhatsApp(String id) {

Cursor c = getSherlockActivity().getContentResolver().query(ContactsContract.Data.CONTENT_URI,
        new String[] { ContactsContract.Contacts.Data._ID }, ContactsContract.Data.DATA1 + "=?",
        new String[] { id }, null);
c.moveToFirst();
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("content://com.android.contacts/data/" + c.getString(0)));

startActivity(i);
c.close();
}

Where id is what's app uri like 0987654321@s.whatsapp.net

这篇关于我怎样才能打开使用联系人数据的WhatsApp的谈话活动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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