0

I am writing a command-line tool for Android (such that it would be called via 'adb shell' or the like, as opposed to being launched via the Android interface).

I want to write something that uses the same kind of information as the 'pm list packages' tool that you can run from an adb shell, which I presume uses getPackageManager() or something like it.

So I've figured out how to compile and run a Java tool in Dalvik, but I can't figure out how to get it the context it needs for getPackageManager to work.

I've also tried writing a "command line" tool using Android Studio by simply not creating any views and by calling my code and then 'finish' in onCreate, but that's not quite right either, as it still briefly takes over the Android interface and it has an icon installed and so forth, which is, I'm fairly certain, not how pm works.

So - how do I write a script like 'pm' that can access installed package info, without creating an Android App?

  • 1
    If you want to make a tool which behaves like `pm` - why won't you look how `pm` is built? https://android.googlesource.com/platform/frameworks/base/+/master/cmds/pm – Alex P. Jun 10 '15 at 18:33
  • Great advice - I'm looking at the source now, though it doesn't really show how pm is built, I don't know much about how to build things with Android.mk, and I'm searching around out how to setup the NDK toolchain. It would be nice to see a step-by-step for what commands I can run to build pm (and/or the other tools in the platform frameworks) – David Ljung Madison Stellar Jun 11 '15 at 06:05
  • Okay, I'm lost now. How do you compile pm? There's an Android.mk, which I've figured out is part of this intricate build system, but I can't find where the base is or the base Makefile. Do I need to download the entire Android system just to compile pm? – David Ljung Madison Stellar Jun 11 '15 at 11:14
  • I've asked the more general question here: http://stackoverflow.com/questions/30946516/android-studio-how-to-build-command-line-android-activity-with-no-view-not-how – David Ljung Madison Stellar Jun 19 '15 at 20:12

0 Answers0