APK 中的 Android APK?

发布于 2024-10-14 10:51:25 字数 261 浏览 2 评论 0原文

正如我上面的问题所述,是否可以在另一个 apk 中包含一个 apk 文件? 为了进一步解释,这是我的情况:

我有两个应用程序,第一个应用程序通过意图调用另一个应用程序。我对此没有问题。但我需要的是仅安装一个 apk 文件而不是两个。我首先想到的是将 .apk 文件放入另一个 .apk 文件中。我真的不知道这是否可能,这就是为什么我需要你对此的看法。但如果这是不可能的,我希望有人能告诉我做这种事情的最佳实践是什么。

我可以将其作为一个应用程序,但这将是我的最后一个解决方案。

As stated in my question above, is it possible to have an apk file within another apk?
To further explain, here is my situation:

I have two apps and the first one calls the other through an intent.. I don't have problem with this.. But what I need is to install only one apk file instead of two. And the first thing that came into my mind is to put a .apk file inside the other .apk file.. I really don't know if this is possible that's why I need your take on this. But if this is not possible, I hope someone can tell me what would be the best practice to doing this kind of thing.

I can make it as one application, but that would be my last solution.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

只想待在家 2024-10-21 10:51:25

我现在刚刚这样做...

我将 apk 2 放入 raw/embeddedapk.apk

然后这段代码...启动了 apk 2 的安装程序... **如果用户手机不允许非市场应用程序,则会出现问题。它将无法安装 apk 2 ...

安装完成后记得删除临时文件...

try {
    InputStream in = this.getResources().openRawResource(R.raw.embeddedapk);

    byte[] b = new byte[in.available()];
    int read = in.read(b);
    toast(read + " byte read");

    String tempFileName = "embeddedapk.apk";
    FileOutputStream fout = openFileOutput(tempFileName, MODE_WORLD_READABLE);

    fout.write(b);      
    fout.close();
    in.close();

    File tempFile = getFileStreamPath(tempFileName);
    Intent i = getFileActionIntent(Intent.ACTION_VIEW, tempFile);

    startActivity(Intent.createChooser(i, "sdsds"));
}
catch (Exception ex){
    Log.e("ero", "erer", ex);
}

我的原因是我希望 apk 1 用户界面和 apk 2 数据提供程序作为市场上的单独应用程序。但我不希望用户在第一次安装时单独关闭...

  • apk 1 需要来自 apk 2 的数据,apk 2 没有任何活动..

  • 当用户从市场下载 apk 1 时,我想自动安装 apk 2 ...

  • 我希望能够更新(市场)apk1 和apk 2 独立...

I just did that right now ...

I put apk 2 in raw/embeddedapk.apk

then this code ... started the installer for apk 2 ... **problem if user phone doesnt allow application not from market .. it will fail to install apk 2 ...

remember to delete temp file when the instalation is finished ....

try {
    InputStream in = this.getResources().openRawResource(R.raw.embeddedapk);

    byte[] b = new byte[in.available()];
    int read = in.read(b);
    toast(read + " byte read");

    String tempFileName = "embeddedapk.apk";
    FileOutputStream fout = openFileOutput(tempFileName, MODE_WORLD_READABLE);

    fout.write(b);      
    fout.close();
    in.close();

    File tempFile = getFileStreamPath(tempFileName);
    Intent i = getFileActionIntent(Intent.ACTION_VIEW, tempFile);

    startActivity(Intent.createChooser(i, "sdsds"));
}
catch (Exception ex){
    Log.e("ero", "erer", ex);
}

My reason is I want to have apk 1 userinterface and apk 2 data provider as seperate apps in market. but i don't wnat users to down then individually when installing first time ...

  • apk 1 need data from apk 2, apk 2 does not have any activities ..

  • When user downloads apk 1 from market I want to auto instal apk 2 ...

  • I want to be able to update (market) apk1 & apk 2 independantly ...

余生一个溪 2024-10-21 10:51:25

也许 Android 库正是您所寻找的。您可以在此处放置一些通用代码并将其包含在多个应用程序 (apk) 中。

请参阅有关库项目的文档。

Perhaps an Android Library is what you are looking for. This is a place where you can put some common code and include it in multiple applications (apks).

See this documentation on library projects.

孤独难免 2024-10-21 10:51:25

抱歉,如果您想在 APK 中添加 APK,那您就不走运了。

Android 不允许您这样做。

但我很好奇你为什么会想要这样?您可以从一项活动调用另一项活动,即使它们位于同一个 APK 中。

Sorry, you are out of luck if you want APK inside APK.

Android does not allow you to do so.

But I am curious about why you would want it that way ?? You can call one activity from the other even if they are in the same APK.

維他命╮ 2024-10-21 10:51:25

您可以将其编程为一个应用程序并具有两个启动器,以便它在用户看来是两个独立的应用程序。

您还可以尝试激发意图并发现没有人对此做出反应的情况。您也可以打开市场并建议安装该应用程序。

最后一种方法主要由需要文件浏览器来选择文件的应用程序完成。他们发送一个意图,如果没有安装文件浏览器,他们会提示一个 toast,通知需要文件浏览器来执行任务,然后他们打开 astro、OI 文件管理器或他们喜欢的其他应用程序的市场页面...

You can program it as one application and having two launcher so that it appears to the user as being two stand alone applications.

You could also try to fire the intent and catch the case that no one is reacting on it. Than you can open the market and recommend to install the application, too.

The last way is mostly done by applications that need file browsers to pick files. They send an intent and if there is no file browser installed, they prompting a toast informing that a file browser is needed to perform the task and they open the market page of astro, OI file manager or another app they prefer...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文