小编Dav*_*eno的帖子

通过编程方式安装 APK Xamarin.Forms (Android)

到目前为止我的代码如下所示:

1.下载APK文件并将其保存到内部存储中:

使用依赖服务

应用程序.xaml.cs

    IDownloader downloader = DependencyService.Get<IDownloader>();

    protected override void OnStart(){
        downloader.OnFileDownloaded+=OnFileDownloaded;
        downloader.DownloadFile("http://localhost:8080/download","folder"); 
    }

    private void OnFileDownloaded(object sender,DownloadEventArgs e) {
        if(e.FileSaved) {
            App.Current.MainPage.DisplayAlert("XF Downloader","File Saved Successfully","Close"); 
        } else {
            App.Current.MainPage.DisplayAlert("XF Downloader","Error while saving the file","Close");
        }
    }
Run Code Online (Sandbox Code Playgroud)

Android:AndroidDownloader.cs

[assembly: Dependency(typeof(NoguianaNucleo.Droid.AndroidDownloader))]
namespace NoguianaNucleo.Droid { 
  public class AndroidDownloader: IDownloader {
    public event EventHandler<DownloadEventArgs> OnFileDownloaded;

    public void DownloadFile(string url,string folder) {

        string pathToNewFolder = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal),folder);
        Directory.CreateDirectory(pathToNewFolder);

        try {
            WebClient webClient = new WebClient();
            webClient.DownloadFileCompleted+=new AsyncCompletedEventHandler(Completed);
            string pathToNewFile = Path.Combine(pathToNewFolder,"nucleo.apk");
            webClient.DownloadFileAsync(new Uri(url),pathToNewFile); …
Run Code Online (Sandbox Code Playgroud)

.net c# android xamarin

6
推荐指数
1
解决办法
2149
查看次数

xaml 设计器或预览器未显示

Xamarin.Forms 设计视图不显示 .xaml 的预览我该怎么办?我寻找答案,我做了所有社区建议,但没有任何效果。我开始认为 Xamarin.Forms 没有 .xaml 的预览,对吗?或者那些按钮在哪里?我怎么能得到它们?

在此处输入图片说明

这是我的观点: 在此处输入图片说明

visual-studio xamarin xamarin.forms xamarin-previewer

3
推荐指数
1
解决办法
1566
查看次数

在 Android、Xamarin.forms 上的整个应用程序中保持沉浸式模式

我想使用 Xamarin.forms 在 Android 上的应用程序中保持沉浸式模式。我读过一些博客和帖子。这个有效,但只有当我按下输入文本框或滚动屏幕时才有效。我想避免这种情况。这个问题争论了我的担忧,但我不明白解决方案。也许它已经过时了。我的 Android 设备是7.1,这是我的.Android MainActivity, ,上的代码void OnCreatevoid OnCreate

public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity{
    protected override void OnCreate(Bundle savedInstanceState){
        Xamarin.Essentials.Platform.Init(this, savedInstanceState);
        global::Xamarin.Forms.Forms.Init(this, savedInstanceState);

        TabLayoutResource = Resource.Layout.Tabbar;
        ToolbarResource = Resource.Layout.Toolbar;
        base.OnCreate(savedInstanceState);
        LoadApplication(new App());

        ImmersiveMode();
    }

    public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Android.Content.PM.Permission[] grantResults){
        Xamarin.Essentials.Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults);

        base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
    }

    public void ImmersiveMode() {
        int uiOptions = (int)(Forms.Context as Activity).Window.DecorView.SystemUiVisibility;
        uiOptions |= (int)SystemUiFlags.Fullscreen;
        uiOptions |= (int)SystemUiFlags.HideNavigation;
        uiOptions |= …
Run Code Online (Sandbox Code Playgroud)

c# android xamarin xamarin.forms android-immersive

3
推荐指数
1
解决办法
1181
查看次数

Java.Lang.NoClassDefFoundError: '失败的解析:Landroidx/arch/core/executor/ArchTaskExecutor;'

我在导入 newtonsoft, json 库时正在编程。突然,当我执行我的应用程序时会显示这个 mesaje。以前从来没有出现过。在此处输入图片说明

我回到了我项目的最后一个成功版本,我也删除了新库。但是当我执行它时,仍然是消息。我还尝试执行一个新的“hello world”Xamarin.Android 应用程序,但它说的是相同的。我无法部署 android 模拟器。看起来我的 Visual Studio 和模拟器都崩溃了。

这是错误代码: 在此处输入图片说明

我能做什么?Desintall 所有的视觉工作室并重新安装它?有没有办法只重新安装 Android 管理设备?

android visual-studio xamarin

1
推荐指数
1
解决办法
1240
查看次数