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

在新的Hangouts Android应用程序中从Intent启动Google Hangout,android,android-intent,hangout,Android,Android Intent,Hangout,这里有之前的讨论,是关于为了安卓而开始谷歌闲逛的: 结论是这是不可能的。这是此处要求的增强: 然而,昨天谷歌发布了一款新的社交网站应用程序,有一套新的意图。现在可以通过intent开始闲逛了吗 我在action=android.intent.action.VIEW,数据方面取得了部分成功=content://plus.google.com/hangouts 但是,我想传递我想呼叫的人的姓名或ID——收件人姓名。我想不出来 新的基于浏览器的hangout应用程序启动一个带有URL的hango

这里有之前的讨论,是关于为了安卓而开始谷歌闲逛的:

结论是这是不可能的。这是此处要求的增强:

然而,昨天谷歌发布了一款新的社交网站应用程序,有一套新的意图。现在可以通过intent开始闲逛了吗

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

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

新的基于浏览器的hangout应用程序启动一个带有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所必需的,但是我无法解释如何在intent中传递收件人名称

有什么想法吗?
谢谢。

嘿,我想你试试这个

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

你只需要给出外挂点的url,但不幸的是,google暂停了命名的外挂点,所以每次都会更改此url。

所以我不知道这是否对其他人有帮助,因为我主要是想使用tasker激发意图。如果你进入Google+>Settings>Contacts,你可以选中“保持联系人最新”,它会在你点击android用户时出现的卡片上添加一些新动作。然后您可以使用读取通过的值。以下是我得到的:

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用户,您可以使用类似的方法打开contacts数据库中的数据表,并查找MIMETYPE_ID=16和DATA4=10的行。你还必须找出你的原始联系人ID。祝你好运

闲逛可以处理一般共享意图

代码如下:

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

        activity.startActivity(sendIntent);
这样试试

下面的方法用于共享要挂起的文本

/**
 * 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;
}
下面的方法用于检查此设备上安装的挂起

/**
 * 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;
}

简单的解决方案是,查询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 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 Allen vnd.android.cursor.item/vnd.googleplus.profile.comm

12562 Allen vnd.android.cursor.item/vnd.googleplus.profile.comm

12564 Allen vnd.android.cursor.item/vnd.googleplus.profile

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

然后你用这种方式开始与那些联系人联系

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+应用程序>设置>联系人中选中“保持联系人最新状态”。

不幸的是,这并不能实现我想要的功能。我知道如何启动应用程序,但我需要能够自动呼叫收件人。换言之,我需要能够通过收件人传达意图。另外,我要说的是,昨天5月15日13日刚刚发布的全新的社交网站应用程序。这与旧的Google+hangout意图不同,Google+hangout意图绝对不允许将收件人传递给意图。你找到了实现这一点的方法吗?我认为这是向前迈出的一步。它确实允许你加入一个聚会,但你仍然需要按下一个按钮。可能有一个参数表示“不要等待按钮按下”。如果有5到6个人在屏幕上乱动,你可能会浪费很多时间!!这正是Android的工作原理,它允许用户选择打开哪个应用程序。您能解释一下如何使用查询获取“数据”值的数量吗?
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);