21

这里有关于从 Android 上的意图启动 Google Hangout 的先前讨论: start google hangouts in android

如何使用 Intent 在 Android 中发起 Google Hangout?

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

然而,昨天谷歌发布了一个新的环聊应用程序,带有一组新的意图。现在可以通过意图开始环聊吗?

我在action=android.intent.action.VIEW,方面取得了部分成功data=content://plus.google.com/hangouts

但是,我想传递我要呼叫的人的姓名或 ID——收件人姓名。我想不通。

新的基于浏览器的环聊应用程序使用如下 URL 开始环聊:

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.

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

有什么想法吗?谢谢你。

4

5 回答 5

5

所以我不知道这是否对其他人有帮助,因为我主要是想使用 tasker 来触发意图。如果您进入 Google+ > 设置 > 通讯录,您可以选中“保持通讯录保持最新”,它会在您点击 Android 中的用户时出现的卡片中添加一些新操作。然后您可以使用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)

我能够使用前三个值正确打开与该联系人的对话。显然,您的数据字段中的数字会根据联系人而变化。你可以使用 Intent Intercept 这个技巧,或者如果你有 root 权限,你可以使用SQLite Debugger之类的东西来破解联系人数据库中的数据表,并找到 MIMETYPE_ID = 16 和 DATA4 = 10 的行。你会有找出你的 RAW_CONTACT_ID 也是什么。祝你好运!

于 2013-07-31T04:03:00.323 回答
2

简单的解决方案是,为 _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章

第12564章

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

然后你像这样向这些联系人发起环聊通话/消息

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+ 应用 > 设置 > 通讯录中选中“让联系人保持最新”。

于 2016-07-30T12:47:47.920 回答
1

环聊可以处理通用共享意图。

这是代码:

        Intent sendIntent = new Intent(Intent.ACTION_SEND);
        sendIntent.setType("text/plain");
        sendIntent.putExtra(Intent.EXTRA_TEXT, "text to be shared");

        activity.startActivity(sendIntent);
于 2014-04-17T18:20:54.513 回答
1

以这种方式尝试

以下方法用于将文本分享到视频群聊

/**
 * Initiate the actions encoded in the specified URI.
 */
public void initiateHangOutUri(Context myContext, String textToShare) {

  // Make sure Android client is installed.
  if (!isHangOutClientInstalled(myContext)) {
    goToMarket(myContext);
    return;
  }

  Intent sendIntent = new Intent();
  sendIntent.setAction(Intent.ACTION_SEND);
  sendIntent.putExtra(Intent.EXTRA_TEXT, textToShare);
  sendIntent.setType("text/plain");
  sendIntent.setPackage("com.google.android.talk");
  context.startActivity(sendIntent);

  return;
}

以下方法用于检查此设备上安装的 HangOut

/**
 * Determine whether the HangOut for Android client is installed on this device.
 **/
public boolean isHangOutClientInstalled(Context myContext) {
  final PackageManager packageManager = context.getPackageManager();
    Intent intent = packageManager.getLaunchIntentForPackage("com.google.android.talk");
    if (intent == null) {
        return false;
    }
    List<ResolveInfo> list = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
    return list.size() > 0;
}

如果未安装 HangOut,以下方法使用 goto playstore

public void goToMarket(Context myContext) {
  Uri marketUri = Uri.parse("market://details?id=com.skype.raider");
  Intent myIntent = new Intent(Intent.ACTION_VIEW, marketUri);
  myIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  myContext.startActivity(myIntent);

  return;
}
于 2016-07-08T11:29:34.133 回答
0

嘿,我想你试试这个。

Intent sky = new Intent("android.intent.action.VIEW", Uri.parse("https://talkgadget.google.com/hangouts/extras/talk.google.com/myhangout"));
startActivity(sky);

您只需要提供环聊的网址,但不幸的是谷歌暂停了命名的环聊,所以这个网址每次都会改变。

于 2013-05-16T05:03:47.283 回答