I’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