如何获得的应用程序的文件的.apk编程如何获得、应用程序、文件、apk

2023-09-12 01:06:40 作者:可惜感动不是心动

我想创建它具有以下功能的应用程序。它应该保存它的 .apk文件文件的 SD卡。想象一下,我有一个按钮。在点击它,我必须保存在 .apk文件文件的应用程序中。

I want to create an application which has the following functionality. It should save its .apk file to the sdcard. Imagine I have a Button. On clicking it I have to save the .apk file of the application.

推荐答案

这是很容易做到这一点。

It is easy to do that..

首先你得到所有安装的应用程序, 对于每一个,得到众源目录。 将文件复制到SD卡。

注:无需植根

下面是snippt code:

Here is the snippt code:

final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
final List pkgAppsList = getPackageManager().queryIntentActivities(mainIntent, 0);
for (Object object : pkgAppsList) {
    ResolveInfo info = (ResolveInfo) object;
    File file = new File(info.activityInfo.applicationInfo.publicSourceDir);
    // Copy the .apk file to wherever
}