Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Start Google Hangout from Intent in New Hangouts Android app

Tags:

There are previous discussions here regarding starting a Google Hangout from an intent on Android: start google hangouts in android

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

The conclusion was that this was not possible. It is a requested enhancement here: https://code.google.com/p/google-plus-platform/issues/detail?id=385

However, yesterday Google released a new Hangouts app, with a new set of intents. Is starting a hangout via intent now possible?

I have been partially successful with action=android.intent.action.VIEW, data=content://plus.google.com/hangouts.

However, I want to pass the name or ID of the person I want to call--the recipient name. I can't figure this out.

The new browser-based hangout app starts a hangout with a URL something like this:

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.

I assume that not all of these parameters are necessary to start a hangout, but I cannot decipher how to pass the recipient name in the intent.

Any thoughts? Thank you.

like image 684
user2388372 Avatar asked May 16 '13 04:05

user2388372


People also ask

What app is replacing Google Hangouts?

Google Hangouts is being upgraded to Google Chat at the end of 2022 for those who haven't already upgraded. Some people may have already moved to Google Chat and may no longer be able to use Google Hangouts on some platforms.

Is Hangouts shutting down in 2021?

After nearly a decade, Google Hangouts will be no more in November. Google Hangouts is officially shutting down in November. The search giant is prompting people still using Hangouts to migrate over to Chat as part of its plan to retire the aging messaging platform, the company said in a blog post Monday.


2 Answers

So I don't know if this helps anyone else because I was mostly looking to fire off an intent using tasker. If you go into Google+ > Settings > Contacts you can check "Keep contacts up to date" and it will add some new actions to card that appears when you click on a user in android. Then you can use Intent Intercept to read the values coming through. Here's what I got:

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)

I was able to use the top three values to properly open a conversation with that contact. Obviously the number in your data field will change depending on the contact. You can either use the trick with Intent Intercept, or if you have root you can use something like SQLite Debugger to crack open the data table in the contacts database and find rows where the MIMETYPE_ID = 16 and the DATA4 = 10. You'll have to find your out what your RAW_CONTACT_ID is too. Good luck!

like image 108
Sean Avatar answered Oct 17 '22 08:10

Sean


Simple solution is, Query ContactContract.Data for the _id and MIME type.

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 );

}

The output will be like the following

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

Now save in DB or somewhere else only those _Ids whose MIME type is vnd.android.cursor.item/vnd.googleplus.profile.comm

And then you initiate hangout call/message with those contacts like this way

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);

For the above code to work you must have to check "Keep contacts up to date" in the Google+ App > Settings> Contacts.

like image 38
Adnan Khan Avatar answered Oct 17 '22 09:10

Adnan Khan