Skip to content

Instantly share code, notes, and snippets.

@bolot
Created June 13, 2017 20:13
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 bolot/27fd371cb13ca4e3318a3af17cdd4dcd to your computer and use it in GitHub Desktop.
Save bolot/27fd371cb13ca4e3318a3af17cdd4dcd to your computer and use it in GitHub Desktop.
adb examples

adb -d logcat -d > log_dump.txt

  • Write the current Android device logs to the file.
  • The first -d applies to adb and means "the only connected device".
  • The second -d applies to logcat and means "dump the contents and exit".

adb -s CAFEBABEDEADBEEF logcat -d > log_dump.txt

  • Same as previous, but connect to the device with the given serial number.

adb shell "pm list packages"

  • Prints the list of packages installed on the device.

adb shell "cmd package list packages -f"

  • Prints the list of packages installed, along with the location of the apk.

adb shell "cmd package query-activities -a android.intent.action.MAIN -c android.intent.category.LAUNCHER"

  • Dumps the information about every activity that is shown in the launcher (i.e., has the launcher intent).

adb shell "am start -n "com.bignerdranch.android.reversible/.LoginActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER"

  • Starts the activity specified by the -n parameter with the launcher action/category (MAIN/LAUNCHER).

adb shell "am start -a android.intent.action.VIEW -d 'https://www.bignerdranch.com'"

  • Starts the VIEW (action specified by -a) intent with the URL specified by -d (data).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment