这里有之前关于在安卓系统上创建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.VIEW,data=content://plus.google.com/hangouts上取得了部分成功。
但是,我想传递要呼叫的人的姓名或ID --收件人姓名。我搞不懂这件事。
新的基于浏览器的hangout应用程序使用类似于以下URL的URL启动hangout:
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所必需的,但我无法破译如何在意图中传递收件人姓名。
有什么想法吗?谢谢。
发布于 2013-07-31 12:03:00
所以我不知道这是否对其他人有帮助,因为我主要是想用tasker来激发一个意图。如果你进入Google+ >设置>联系人,你可以勾选“保持联系人更新”,它会在你点击安卓用户时出现的卡片上添加一些新的动作。然后,您可以使用Intent Intercept读取传入的值。下面是我得到的信息:
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是什么。祝好运!
发布于 2016-07-30 20:47:48
简单的解决方案是查询_id和MIME类型的ContactContract.Data。
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呼叫/消息
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>联系人中选中“保持联系人更新”。
发布于 2014-04-18 02:20:55
Hangout可以处理通用的共享意图。
代码如下:
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setType("text/plain");
sendIntent.putExtra(Intent.EXTRA_TEXT, "text to be shared");
activity.startActivity(sendIntent);https://stackoverflow.com/questions/16579228
复制相似问题