首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在新Hangout Android应用程序中从Intent启动Google Hangout

在新Hangout Android应用程序中从Intent启动Google Hangout
EN

Stack Overflow用户
提问于 2013-05-16 12:51:05
回答 5查看 13.3K关注 0票数 21

这里有之前关于在安卓系统上创建Google Hangout的讨论:start google hangouts in android

How can I start a Google Hangout in Android with an Intent?

结论是这是不可能的。这是一个请求的增强:https://code.google.com/p/google-plus-platform/issues/detail?id=385

然而,昨天谷歌发布了一个新的Hangout应用程序,有了一套新的意图。现在可以通过intent开始一次闲逛了吗?

我已经在action=android.intent.action.VIEWdata=content://plus.google.com/hangouts上取得了部分成功。

但是,我想传递要呼叫的人的姓名或ID --收件人姓名。我搞不懂这件事。

新的基于浏览器的hangout应用程序使用类似于以下URL的URL启动hangout:

代码语言:javascript
复制
https://plus.google.com/hangouts/_/CONVERSATION/[26-character ID]?hl=en_US&hscid=[19-digit ID]&hpe=[14-character value]&hpn=[Google+ Name of Recipient]&hnc=0&hs=41.

我假设并非所有这些参数都是启动hangout所必需的,但我无法破译如何在意图中传递收件人姓名。

有什么想法吗?谢谢。

EN

回答 5

Stack Overflow用户

发布于 2013-07-31 12:03:00

所以我不知道这是否对其他人有帮助,因为我主要是想用tasker来激发一个意图。如果你进入Google+ >设置>联系人,你可以勾选“保持联系人更新”,它会在你点击安卓用户时出现的卡片上添加一些新的动作。然后,您可以使用Intent Intercept读取传入的值。下面是我得到的信息:

代码语言:javascript
复制
ACTION: android.intent.action.VIEW
DATA: content://com.android.contacts/data/5555
TYPE: vnd.android.cursor.item/vnd.googleplus.profile.comm

FLAGS:
FLAG_ACTIVITY_FORWARD_RESULT
FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
FLAG_ACTIVITY_PREVIOUS_IS_TOP

1 ACTIVITIES MATCH THIS INTENT:
Hangouts (com.google.android.talk - com.google.android.apps.babel.phone.BabelProfileActionActivity)

我能够使用前三个值正确地打开与该联系人的对话。显然,数据字段中的数字将根据联系人的不同而变化。你可以使用意图拦截的技巧,或者如果你有根用户,你可以使用像SQLite Debugger这样的东西来打开contacts数据库中的数据表,找到MIMETYPE_ID = 16和DATA4 = 10的行。你也必须弄清楚你的RAW_CONTACT_ID是什么。祝好运!

票数 5
EN

Stack Overflow用户

发布于 2016-07-30 20:47:48

简单的解决方案是查询_id和MIME类型的ContactContract.Data。

代码语言:javascript
复制
ContentResolver resolver = context.getContentResolver();  
cursor = resolver.query(
            ContactsContract.Data.CONTENT_URI,
            null, null, null,
            ContactsContract.Contacts.DISPLAY_NAME);

//Now read data from cursor like 

while (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.googleplus.profile.comm

12562艾伦vnd.android.cursor.item/vnd.googleplus.profile.comm

12564艾伦vnd.android.cursor.item/vnd.googleplus.profile

现在只将MIME类型为vnd.android.cursor.item/vnd.googleplus.profile.comm的那些_Ids保存到DB或其他地方

然后,您可以像这样向这些联系人发起hangout呼叫/消息

代码语言:javascript
复制
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.googleplus.profile.comm");
            intent.setPackage("com.google.android.talk");

startActivity(intent);

要让上面的代码正常工作,您必须在Google+应用程序> Settings>联系人中选中“保持联系人更新”。

票数 2
EN

Stack Overflow用户

发布于 2014-04-18 02:20:55

Hangout可以处理通用的共享意图。

代码如下:

代码语言:javascript
复制
        Intent sendIntent = new Intent(Intent.ACTION_SEND);
        sendIntent.setType("text/plain");
        sendIntent.putExtra(Intent.EXTRA_TEXT, "text to be shared");

        activity.startActivity(sendIntent);
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16579228

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档