简体   繁体   English

如何使用Xamarin表单自动安装apk?

[英]how to auto install apk using Xamarin forms?

I want to auto install apk using Xamarin Forms. 我想使用Xamarin Forms自动安装apk。 I'm able to get the install screen of the apk using my code but that makes me install the app manually. 我可以使用我的代码获取apk的安装屏幕,但这使我可以手动安装该应用程序。 This is my code 这是我的代码

public void ApkInstall()
{

            try
            {


                var filename = "XYZ.apk";

                System.Diagnostics.Debug.WriteLine("The file name is" + filename);
                var path = "Install apk/";
                var destination = Path.Combine(Android.OS.Environment.ExternalStorageDirectory.AbsolutePath.ToString(), path + filename);
                System.Diagnostics.Debug.WriteLine("The destination is" + destination);
                //Android.Net.Uri uri = Android.Net.Uri.("file://" + destination);
                Intent install = new Intent(Intent.ActionInstallPackage);
                //install.PutExtra(Intent.ExtraNotUnknownSource, true);
                //install.AddFlags(ActivityFlags.ClearTask);


                install.SetDataAndType(Android.Net.Uri.FromFile(new Java.IO.File(Android.OS.Environment.ExternalStorageDirectory.AbsolutePath.ToString() + "/Install apk/" + filename)), "application/vnd.android.package-archive");
                install.SetFlags(ActivityFlags.ClearTask|ActivityFlags.NewTask);
                install.AddFlags(ActivityFlags.GrantReadUriPermission);
                Forms.Context.StartActivity(install);
                //Forms.Context.UnregisterReceiver(this);

            }

Right now I'm getting this installation page 现在我得到这个安装页面 在此处输入图片说明 But I should start installing the app automatically. 但是我应该开始自动安装该应用程序。 Instead of manually installing the app from install screen. 而不是从安装屏幕手动安装应用程序。

I have checked lots of resources and I think that auto install is not possible because of security issues. 我检查了很多资源,并且由于安全问题,我认为无法进行自动安装。 These are the links which I referred 这些是我提到的链接

How can I auto install apk on android without market NOT system app 我如何在没有市场NOT系统应用程序的情况下在Android上自动安装APK

make auto install app in android easier? 使Android中的自动安装应用更加容易?

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

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