当文件下载完成时,如何自动安装APK(私人托管) [英] How to install APK automatically when the file download is complete (hosted on private)

查看:102
本文介绍了当文件下载完成时,如何自动安装APK(私人托管)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Android的新手,而且我最近两天一直在搜索网络。我也找到了以下链接,但是我完全没有得到如何和在哪里实现这个代码开始自动安装apk文件,以及如何在安装后删除下载的apk文件。请指导我正确的方式。

I am new to android and i have been searching the web from last two days for this. I found following links too but i am not getting how and where to implement this code to start automatic installation of the apk file after it downloads completely and how to delete the downloaded apk file after installation. Please help me by guiding me the right way.

如何以编程方式安装apk文件

在另一个android应用程序中从APK调用活动

安装Android以编程方式安装apk

Install APK programmatically on android

http://www.anddev.org/viewtopic.php?p=23928

编辑:

我在清单文件中写了这段代码:

i have written this code in manifest file :

<uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.WRITE_CONTACTS" />
    <!-- <uses-permission android:name="android.permission.INSTALL_PACKAGES"/> -->
    <application android:icon="@drawable/biz_logo"
        android:permission="android.permission.WRITE_CONTACTS">
        <activity android:name="com.biz.mlm.Main">
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:scheme="content" />
                <data android:scheme="file" />
                <data android:mimeType="application/vnd.android.package-archive" />
            </intent-filter>
        </activity>


推荐答案

不可能。正如其中一些链接指出的那样,自动安装APK并删除原始安装程序,而无需进一步的用户干预就被称为恶意软件。

Not possible. As some of those links point out, making an APK that automatically installs itself and deletes the original installer without any further user intervention is called malware.

您可以编写一个程序,如果用户授予相关权限,将会下载并安装任意的APK,但是我还没有看到一个很好的实现或文档。通常您可以使用以下代码调用默认系统安装程序:

You can write a program that will download and install arbitrary APKs if the user grants it the relevant permissions, but I'm yet to see a good implementation or documentation for this. Typically you can invoke the default system installer using code like this:

File apkFile = new File({path to APK});
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setDataAndType(Uri.fromFile(apkFile), "application/vnd.android.package-archive");
    startActivity(intent);

这篇关于当文件下载完成时,如何自动安装APK(私人托管)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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