How to call getPackageManager() from Android command-line executable
问题 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