需要一些帮助,通过检索Android设备programmaticaly *的.apk文件名?难道任何机构提供了一些Android的方法这样做,还是Android下运行,即使外壳命令来获取文件的位置,如果我知道只是一部分,从文件名?
Need some help by retrieving *.apk file name from Android device programmaticaly ? Could any body provide some Android methods doing that or even shell commands run under Android to get the file location , if I know just a part from file name ?
另外,如果有一种方法如何找出从市场或市场外下载完成后,*的.apk文件去了?
Also if there is a way how to find out where the *.apk file went after downloading from Market or outside Market ?
感谢你在前进。
推荐答案
List<ApplicationInfo> PackageManager.getInstalledApplications() 会给你安装的应用程序的列表,ApplicationInfo.sourceDir是路径的.apk文件
List<ApplicationInfo> PackageManager.getInstalledApplications()
will give you a list of the installed applications, and ApplicationInfo.sourceDir
is the path to the .apk file.
PackageManager pm = getPackageManager();
for (ApplicationInfo app : pm.getInstalledApplications(0)) {
Log.d("PackageList", "package: " + app.packageName + ", sourceDir: " + app.sourceDir);
}
输出是这样的:
Outputs something like this:
package: com.tmobile.themechooser, sourceDir: /system/app/ThemeChooser.apk
package: com.tmobile.thememanager, sourceDir: /system/app/ThemeManager.apk
package: com.touchtype.swiftkey, sourceDir: /data/app/com.touchtype.swiftkey-1.apk
package: com.twitter.android, sourceDir: /data/app/com.twitter.android-2.apk
package: fm.last.android, sourceDir: /data/app/fm.last.android-1.apk
相关推荐
最新文章