Android 一个安卓应用可以安装另一个安卓应用吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3095726/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 08:40:47  来源:igfitidea点击:

Can an Android app install another android app?

androidinstall

提问by Anton

I was wondering if it was possible to have an android app which is already installed go and download another app and install it? I figure there could be security problems with this, but is it possible for the Android OS to do this?

我想知道是否有可能有一个已经安装的 android 应用程序去下载另一个应用程序并安装它?我认为这可能存在安全问题,但 Android 操作系统有可能做到这一点吗?

回答by lornova

Strictly speaking no, it is not possible: each Android package (.apk) file installed on the device is given its own unique Linux user ID, creating a sandbox for it and preventing it from touching other applications.
If an application would "install" another one, it couldn't give to the target a new user ID. Only the system applet, running at root level, can do that.

严格来说,这是不可能的:安装在设备上的每个 Android 包 (.apk) 文件都有自己唯一的 Linux 用户 ID,为其创建一个沙箱并防止它接触其他应用程序。
如果一个应用程序要“安装”另一个应用程序,它就不能给目标一个新的用户 ID。只有在根级别运行的系统小程序才能做到这一点。

What the application can do is to indirectly invoke the package installer with the ACTION_VIEWintent and the application/vnd.android.package-archiveMIME type: the system will launch the appropriate "viewer", which of course is the package installer.

应用程序可以做的是使用ACTION_VIEW意图和application/vnd.android.package-archiveMIME 类型间接调用包安装程序:系统将启动适当的“查看器”,这当然是包安装程序。

Nice link about that topic: http://android.amberfog.com/?p=98

关于该主题的不错链接:http: //android.amberfog.com/?p=98

回答by Robby Pond

Yes. This is how the Swype beta works. What you basically do is download the new apk, and use some Intent (not sure which) to launch the Package Installer (and at this point it is a new activity and the user has to agree to install just like downloading from the Market).

是的。这就是 Swype 测试版的工作原理。您基本上要做的是下载新的 apk,并使用一些 Intent(不确定是哪个)来启动 Package Installer(此时这是一个新活动,用户必须同意安装,就像从市场下载一样)。

回答by DroidlikeCode

Try this:

尝试这个:

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File(path+"/yourapp.apk")), application/vnd.android.package-archive");
startActivity(intent);

回答by Vishal


If the answer is NO. Then i wonder how facebook installs "Messenger"Application along with the "Facebook for Android"application?

If i'm not wrong, "Messenger" is also a different application from Main Facebook app.

Facebook For Android App will not ask to install Messenger App when we want to chat thru facebook app. It is already installed with facebook.

You can also install/uninstall Messenger application separately.

I may be wrong. I dont have complete information, but looking at the process and on applying little bit of logic i think we can install android application from another application. But how i'm too learning and looking for it .


如果答案是否定的。然后我想知道 facebook 如何安装“Messenger”应用程序和“Facebook for Android”应用程序?

如果我没记错的话,“Messenger”也是与 Facebook 主应用程序不同的应用程序。

当我们想通过 facebook 应用程序聊天时,Facebook For Android 应用程序不会要求安装 Messenger 应用程序。它已经安装在 facebook 上。

您还可以单独安装/卸载 Messenger 应用程序。

我可能是错的。我没有完整的信息,但是查看过程和应用一点点逻辑,我认为我们可以从另一个应用程序安装 android 应用程序。但是我太在学习和寻找它了。


So how must they have done it? Please correct me if i'm wrong.


那么他们是如何做到的呢?如果我错了,请纠正我。

回答by Partial Science

If your app is root privlaged you can move the apk you want to install into /data/app and it will install when the device reboots

如果您的应用程序是 root privlaged,您可以将要安装的 apk 移动到 /data/app 中,它会在设备重新启动时安装