简体   繁体   English

使用Xamarin从运行时安装APK

[英]Install APK from runtime using Xamarin

I'm trying to make a standalone update solution for a private project. 我正在尝试为私人项目提供独立的更新解决方案。 As per a question from StackOverflow, I'm checking versions against an apk on a web server and if there is mismatch am downloading the new .apk, but don't know how to install it from there. 按照StackOverflow的一个问题,我正在针对Web服务器上的apk检查版本,如果不匹配,请下载新的.apk,但不知道如何从那里安装它。 Any ideas how this might happen? 任何想法如何发生?

I've seen this done before, this snippet might work. 我之前已经看过此代码,此代码段可能会起作用。 The UpdatePackageUri is of type Android.Net.Uri UpdatedPackageUri UpdatePackageUri类型为Android.Net.Uri UpdatedPackageUri

/// <summary>
    /// Starts the installer.
    /// </summary>
    /// <param name="context">The context.</param>
    public void StartInstaller(Context context)
    {
        var intent = new Intent(Intent.ActionView);
        intent.SetDataAndType(UpdatedPackageUri, "application/vnd.android.package-archive");
        intent.SetFlags(ActivityFlags.NewTask);
        context.StartActivity(intent);
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM