小编Teu*_*ozz的帖子

我应该等待AutoView吗?

我正在研究一个项目,我们正在使用MvvmCross框架.该项目应在二月份完成.我们想知道我们是否应该等待AutoView作为跨平台UI解决方案,或者将在2月即将推出?

我们现在遇到的问题是我们希望能够动态构建BindableListView.然后列表中的每个项目都可以有不同的布局和视图集,例如,当我有任意顺序的字符串和整数列表列表时,BindableListView将为每个字符串显示一个TextView,为每个int显示一个数字选择器.

像这样的东西:

public ElementDescription DefaultView()
{
    var auto = new RootAuto(caption: "TestRootElement")
    {
        new SectionAuto(header: "Test Info")
            {
                foreach(item s in list)
                {
                    if(s.GetType() == typeof(string) )
                        new StringAuto();
                    if(s.GetType() == typeof(int)
                        new IntAuto();
                }              
            };

        return auto.ToElementDescription();
    }
}
Run Code Online (Sandbox Code Playgroud)

使用AutoView可以实现这一点吗?或者我们应该寻找不同的解决方案?

mvvmcross

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

为什么我的绑定前台服务被Android Oreo停止了?

我创建了一个需要在后台不断扫描我们自己的蓝牙设备的应用程序。当其中一个蓝牙设备在附近时,应用程序需要采取某些措施。

我使用绑定的前台服务扫描蓝牙设备,当附近有设备时,应用程序开始侦听位置更新。当设备不在附近时,应用会停止位置更新,然后再次开始扫描。直到奥利奥(Oreo)为止,这一直很好。

在Android Oreo上,该服务通常会在运行2-3天后停止。而且我不知道为什么会这样。

这是我在主要活动中创建服务的方式:

private void initServiceConnection() {
    mServiceConnection = new ServiceConnection() {
        @Override
        public void onServiceConnected(ComponentName componentName, IBinder service)
        {
            mService = ((MyService.LocalBinder) service).getService();
            mService.startBLEScan();
        }

        @Override
        public void onServiceDisconnected(ComponentName componentName)
        {
            // When the service is killed we restart the app in onDestroy by calling finish() here
            mService = null;
            finish();
        }
    };

    Intent serviceIntent = new Intent(this, MyService.class);
    bindService(serviceIntent, mServiceConnection, BIND_AUTO_CREATE | BIND_IMPORTANT);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        startForegroundService(serviceIntent);
    }
}
Run Code Online (Sandbox Code Playgroud)

这是该服务的简化版本:

public class MyService extends …
Run Code Online (Sandbox Code Playgroud)

android foreground-service android-8.0-oreo

5
推荐指数
0
解决办法
689
查看次数