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

查看:24
本文介绍了文件下载完成后如何自动安装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

在 android 上以编程方式安装 APK

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天全站免登陆