Jeff Mixon

Just another WordPress site. Literally.

RSS Feed

How to programmatically sign out of Google Talk on Android

Google Talk LogoI’ve recently been experimenting with NFC automation. Unlike geo-location based automation, I think NFC offers the flexibility and precision to actually be useful. But more on NFC in another post. One thing I wanted to do was sign in and out of Google Talk when scanning certain tags. I quickly found info on how to sign in, but there was nothing on how to sign out Google Talk programmatically. It was a problem I couldn’t resist solving.

I pulled the Jelly Bean version of the Talk.apk from my phone, decompiled the APK and the JAR, and began browsing the surprisingly (and thankfully) unobfuscated code. It wasn’t long before I came across the SignoutActivity class and gleaned the following solution:

Intent to sign off from Google Talk

am start -a android.intent.action.MAIN -n com.google.android.talk/com.google.android.talk.SignoutActivity -d content://com.google.android.providers.talk/accounts

You’ll see the key portions are addressing the SignoutActivity directly and passing that URI as the Data portion of the Intent. That, combined with the following sign on syntax, is everything you need to automate your Google Talk online status, whether it is with NFC tags or your own app:

Intent to sign in to Google Talk

am start -a android.intent.action.MAIN -n com.google.android.talk/com.google.android.talk.SigningInActivity

Cheers.

Tags: , , , , , , , , .
  • Trackbacks
  • Comments
  • Ben
    July 26, 2012

    Is there any way to sign in and out of specific accounts? I have multiple accounts on the phone and the given intents seem to pick the first.

    • Jeff
      July 31, 2012

      Didn’t see any obvious way the first time I looked. I’ll break open the Chat code again soon and let you know if I find anything.

      • kanylbullen
        October 18, 2012

        Works great! I would too like to be able to sign out all of the accounts though. I also couldnt figure out how to use the intent with Taskers “Send Intent” do you think you could figure out what goes where in theese boxes? http://bit.ly/S7jdfB It’s really hard to find any documentation about theese intents and how they work.

  • overground
    August 3, 2012

    Awesome work with this, Jeff. Really interesting to read.
    overground@xda

  • Smegger
    September 25, 2012

    So what do i need to actually type into my nfc tag to send a message to somone? ive tried gtalk:chat?jid=xxx@gmail.com but Talk just wont open. Ive tried xmpp too

  • Mihara
    October 8, 2012

    I’ve seen these intent calls before. Unfortunately, for one reason or another, they seem very erratic. Sometimes signing out works. Sometimes it doesn’t. Sometimes signing in works (on the first account in the list only, but that’s the one I wanted to automate anyway.) and sometimes it doesn’t.

    It clearly needs more research. :)

  • eric
    August 6, 2013

    Hey guys. Just got this working with a Tasker intent on an S4 with 4.2.2. I was able to log out of my second account by adding a /2 to the data field. I’d assume /3, /4, etc would work. I was planning to use an NFC tag to log out of my work chat support when I leave the ooffice. We’ll see how this plays out. Thanks for getting me on the right path!

  • root
    January 10, 2014

    Anyway to do this on the new hangouts? com.google.android.talk.SignoutActivity no longer exists :-(

    [WORDPRESS HASHCASH] The poster sent us ‘0 which is not a hashcash value.

  • No trackbacks yet.

Leave a Reply

*