Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Notifications through ADB

I'm writing a shell script that allows you to install an .apk on all android phones connected to a computer in parallel using Terminal. At my company we do tests on many devices and so this makes the installation part must faster.

Question: I'm looking for a way to quickly identify which phones have had the .apk installed via some sort of feedback/notification. Ideally you should be able to see which phones have received the .apk just by looking at it (some sort of sound or screen flash) or simply by unlocking the device (ex. the newly installed app has been opened).

Any ideas of how I could do either of these things?

I've read about launching apps but it seems like thats not something you could do with just the .apk (you would also need to specify an activity...).

Any ideas would be much appreciated!

Thanks!

like image 920
HaroldT Avatar asked Jul 06 '12 03:07

HaroldT


1 Answers

Found my own solution!

I was using:

aapt dump badging

thinking that this would just output the package name. Turns out it outputs a lot more of useful info. One of the lines I noticed was output is the launch activity of the app. I was able to isolate this line with grep and then cut out the launch activity as so:

aapt dump badging $1 | grep launchable | cut -d "'" -f 2

Then there is a command that allows you to launch an app if you know one of it's activities. Adding this line launches the activity that was retrieved using the above command.

adb -s $deviceID shell am start -a android.intent.action.MAIN -n $packageName/$launchableActivity

I placed this line in my for loop right after the install command. No after the app is installed the script will attempt to launch it afterwards. Very handy!

Thanks for all the help! :D

like image 135
HaroldT Avatar answered Nov 05 '22 22:11

HaroldT