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活动文件中使用此代码示例,并将其与您的其他代码整合。

相关内容

热门资讯

透视好牌"hhpok... 透视好牌"hhpoker是内部控制吗"详细辅助解说技巧(轻量版透视系统软件)是由北京得hhpoker...
透视苹果版"aapo... 透视苹果版"aapoker透视怎么用"详细辅助2025新版总结(辅助软件价格辅助);支持2-10人实...
透视游戏"aapok... 透视游戏"aapoker怎么选牌"详细辅助透明教程(可以看底牌透视)是由北京得aapoker怎么选牌...
透视安装"hhpok... 1、透视安装"hhpoker辅助器"详细辅助系统教程(透视底牌脚本技巧)。2、hhpoker辅助器透...
透视总结"wepok... 透视总结"wepoker有用吗"详细辅助解密教程(可以下载游戏技巧);《WPK辅助透视》‌:支持手机...
透视ai"wepok... 透视ai"wepoker辅助器有哪些功能"详细辅助黑科技教程(私人定制透视软件);最新版2024是一...
透视存在"werpl... 《透视存在"werplan透视挂"详细辅助分享教程(国外版透视神器)》 werplan透视挂软件透明...
透视线上"wepok... 透视线上"wepoker辅助透视软件"详细辅助力荐教程(透视版下载辅助);1分钟了解详细教程(微信 ...
透视插件"德普之星透... 透视插件"德普之星透视软件免费入口官网"详细辅助wepoke教程(辅助器辅助)1、许多玩家不知道德普...
辅助透视"wepok... 辅助透视"wepoker破解工具"详细辅助总结教程(私人局透视教程神器);人气非常高,ai更新快且高...