如何获得的应用程序的文件的.apk编程 [英] How to get the .apk file of an application programatically

查看:117
本文介绍了如何获得的应用程序的文件的.apk编程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建它具有以下功能的应用程序。它应该保存它的 .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..

  1. 首先你得到所有安装的应用程序,
  2. 对于每一个,得到众源目录。
  3. 将文件复制到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
}

这篇关于如何获得的应用程序的文件的.apk编程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆