首页 > 解决方案 > Xamarin Android ForceDarkHelper 是什么?

问题描述

应用程序会定期开始自我更新。日志中有一个不断的调用:

[ForceDarkHelper] updateByCheckExcludeList: pkg: com.companyname.manimobile activity: crc64d14753dcc52b83b4.MainActivity@a894c70
[ForceDarkHelper] updateByCheckExcludeList: pkg: com.companyname.manimobile activity: crc64d14753dcc52b83b4.MainActivity@a894c70
[ForceDarkHelper] updateByCheckExcludeList: pkg: com.companyname.manimobile activity: crc64d14753dcc52b83b4.MainActivity@a894c70
[ForceDarkHelper] updateByCheckExcludeList: pkg: com.companyname.manimobile activity: crc64d14753dcc52b83b4.MainActivity@a894c70

发生这种情况时,例如,如果您打开菜单,它会自行关闭,如果填写了某些内容,则将其清除,页面会更新。代码中没有计时器。我正在小米红米上测试该应用程序。我重复有时它会发生有时它不会。它是什么?

我不知道问题是什么,但偶尔会发生应用程序将指纹扔到页面上。它是间歇性的。有时一切正常。也就是说,我通过指纹,下一页打开,一切正常,5 秒后我再次被扔到需要输入指纹的页面。授权页面代码:

public authentification()
    {
        try
        {

        InitializeComponent();
        bool auth = CrossSettings.Current.GetValueOrDefault("authorized", false);
        if (auth == false) { CheckAuth(); }
        else
        {
            Application.Current.MainPage = new MasterLk();

        }

        }
        catch { }
    }
    async void CheckAuth()
    {
        try
        {


            var avail = await CrossFingerprint.Current.IsAvailableAsync();
            if (!avail)
            {
                CrossSettings.Current.GetValueOrDefault("authorized", true);
                Application.Current.MainPage = new MasterLk();
            }
            else
            {
                var request = new AuthenticationRequestConfiguration("NeedAuth", "-");
                var result = await CrossFingerprint.Current.AuthenticateAsync(request);
                if (result.Authenticated)
                {
                  CrossSettings.Current.GetValueOrDefault("authorized", true);
                  Application.Current.MainPage = new MasterLk();
                }
                else
                {
                    CheckAuth();
                  
                }
            }
        }
        catch { }

    }

在它抛出它的页面上有一个带有绑定的 ListView:

public class OrdersViewModel : BaseViewModel
    {
        private Table oldLoan;
        private bool isRefreshing;
        private readonly string clientId;
 
 
        public bool IsRefreshing
        {
            get
            {
                return isRefreshing;
            }
            set
            {
                isRefreshing = value;
                OnPropertyChanged("IsRefreshing");
            }
        }
        public ICommand RefreshCommand { get; set; }
 
        public ObservableCollection<Table> Loans { get; set; }
 
        public void ShowOrHideLoan(Table loan)
        {
            if (oldLoan == loan)
            {
                loan.IsExpanded = !loan.IsExpanded;
                Reload(loan);
 
            }
            else
            {
                if (oldLoan != null)
                {
                    oldLoan.IsExpanded = false;
 
                    Reload(oldLoan);
                }
                loan.IsExpanded = true;
                Reload(loan);
 
            }
            oldLoan = loan;
        }
        private void Reload(Table loan)
        {
            var index = Loans.IndexOf(loan);
            Loans.Remove(loan);
            Loans.Insert(index, loan);
        }
        public async Task LoadDataAsync()
        {
            IsRefreshing = true;
            Loans.Clear();
            try
            {
                var loans = await ConnectAPI.GetOrdersAsync(clientId);
                await Task.Delay(1000);
                foreach (var item in loans)
                {
                    Loans.Add(item);
                }
            }
            catch (Exception exc)
            {
                Console.WriteLine(exc.Message);
            }
            finally
            {
                oldLoan = null;
                IsRefreshing = false;
            }
        }
        public OrdersViewModel(string clientId) 
        {
            IsRefreshing = false;
            this.clientId = clientId;
            Loans = new ObservableCollection<Table>();
            RefreshCommand = new Command(async () =>
            {
                await LoadDataAsync();
            });
            Task.Run(async () => await LoadDataAsync());
        }
    }

即每当[ForceDarkHelper] updateByCheckExcludeList: pkg: com.companyname.manimobile 活动: crc64d14753dcc52b83b4 事件出现。MainActivity@a894c70 将其扔到打印页面...如果您停留在此页面上,它会在一段时间后更新。

标签: c#androidxamarin

解决方案


MIUI 12 做了智能深色主题。如果应用程序不支持深色主题,系统本身会重新绘制应用程序。显然这项服务是 ForceDarkHelper。而ExcludeList在设置中是不能重绘的应用列表


推荐阅读