Skip to content

Instantly share code, notes, and snippets.

@nvlled
Created September 14, 2018 05:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nvlled/1039dabe8fab4e1a91f21b12c23a107b to your computer and use it in GitHub Desktop.
Save nvlled/1039dabe8fab4e1a91f21b12c23a107b to your computer and use it in GitHub Desktop.
#!/bin/bash
# Gets the main activty of the android project
# Run at project root folder
# output like: com.package.sub/com.package.sub.MainActivity
# Purpose: use with android am for running the installed apk
activity=$(cat `find app/src -iname "AndroidManifest.xml"` | grep -i '<activity android:name' | sed 's/.*="\(.*\)".*/\1/')
activity=$(echo $activity | sed 's/^\.//')
dir=$(dirname `find app/src -name "$activity.*"`)
dir=$(echo $dir | sed 's@app/src/main/java/@@')
package=$(echo $dir | sed 's@/@.@g')
echo $package/$package.$activity
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment