Android Xamarin Form Targeting S+ (Version 31及以上)要求使用FLAG_IMMUTABLE或FLAG_MUTABLE之一
创始人
2024-08-19 12:30:18
0

在Android Xamarin Forms中,您可以使用以下代码示例解决Targeting S+ (Version 31及以上)要求使用FLAG_IMMUTABLE或FLAG_MUTABLE之一的问题:

using Xamarin.Forms.PlatformConfiguration;
using Xamarin.Forms.PlatformConfiguration.AndroidSpecific;
using Android.Views;

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

        // 设置WindowFlags以满足Android S+要求
        if (Build.VERSION.SdkInt >= BuildVersionCodes.S)
        {
            Window.SetFlags(WindowManagerFlags.Immutable, WindowManagerFlags.Immutable);
        }

        Xamarin.Essentials.Platform.Init(this, savedInstanceState);
        global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
        LoadApplication(new App());
    }
}

这里的关键是在OnCreate方法中设置WindowFlags以满足Android S+要求。在Android S及更高版本中,必须设置WindowManagerFlags.ImmutableWindowManagerFlags.Mutable之一来指示窗口的可变性。

请确保在MainActivity.cs或您的主要Android活动文件中使用此代码示例,并将其与您的其他代码整合。

相关内容

热门资讯

透视练习!德州来玩辅助器(透视... 透视练习!德州来玩辅助器(透视)其实真的有辅助平台(哔哩哔哩)1、完成德州来玩辅助器有辅助插件,帮助...
透视教程书!德普之星透视辅助软... 透视教程书!德普之星透视辅助软件是真的吗(透视)确实存在有辅助工具(哔哩哔哩)1、透视教程书!德普之...
透视手册!约局吧德州有挂吗(透... 透视手册!约局吧德州有挂吗(透视)好像是真的辅助app(哔哩哔哩)1、游戏颠覆性的策略玩法,独创攻略...
透视模板!we-poker靠谱... 透视模板!we-poker靠谱吗(透视)好像是有辅助神器(哔哩哔哩)1)we-poker靠谱吗有没有...
透视项目!德普之星有辅助软件吗... 透视项目!德普之星有辅助软件吗(透视)好像是有辅助工具(哔哩哔哩)1、全新机制【德普之星有辅助软件吗...
透视操作!wepoker怎么发... 透视操作!wepoker怎么发冤家牌(透视)竟然真的是有辅助软件(哔哩哔哩)1、下载好wepoker...
透视法门!德州辅助工具到底怎么... 透视法门!德州辅助工具到底怎么样(透视)一贯有辅助神器(哔哩哔哩)1、金币登录送、破产送、升级送、活...
透视方式!pokemmo脚本(... 透视方式!pokemmo脚本(透视)本来真的是有辅助安装(哔哩哔哩)pokemmo脚本是不是有人用挂...
透视绝活!wepoker怎么挂... 透视绝活!wepoker怎么挂底牌(透视)其实存在有辅助软件(哔哩哔哩)1、透视绝活!wepoker...
透视模板!拱趴游戏破解器(透视... 透视模板!拱趴游戏破解器(透视)本来真的是有辅助修改器(哔哩哔哩)1、进入到拱趴游戏破解器是否有挂之...