
问题记录
文章平均质量分 79
山雨楼
山雨雨来风满楼
展开
-
Android ViewModel LiveData observe onChanged 方法只执行第一次问题
类似问题发生前提onChanged 回调中发生异常setValue被包含在外部try catch中onChanged函数中没有做异常捕获在网络回调中设置setValue很常见,如果在异常中又没有将异常展示,问题将很难发现,这里记录下。原创 2023-06-28 11:21:03 · 801 阅读 · 0 评论 -
Android 10(Q) multi-resume(多项恢复)带来的问题
在项目中,ActivityA启动ActivityB,ActivityB启动系统图片选择器,如果从系统图片选择器返回,这个时候ActivityA和ActivityB同时都会回调onResume方法,这个时候如果ActivityA中的onResume方法里有代码执行,而且又不希望在后台中执行就会出问题。那么问题又来了为啥Android 10会做出这样的改变呢,原来是为了兼容多窗口多屏幕,应用在上述设备同一个应用可以有多个resume状态下的Activity,具体可以参照。原创 2022-09-14 17:41:22 · 1004 阅读 · 0 评论 -
Android 在Service中使用ViewModel
别想了,官方并不推荐这种做法。ViewModel应该与Activity或Fragment紧密结合使用,因此它注定要存在于应用程序的UI层中。因此,我不建议在Service中使用ViewModel。可以将Service和ViewModel的公共代码抽出。具体参考:https://github.com/android/architecture-components-samples/issues/137#issuecomment-327854042The ViewModel should be used原创 2020-12-04 11:53:00 · 5853 阅读 · 4 评论 -
Android Gradle 打包时排除 Assets 目录指定文件
直接上代码,排除 Assets 目录或者子目录下的 qaa.js,ccc.css,bbb.t 这3个文件,多个文件以!开头:结尾。当一个文件夹下所有文件都排除后,空文件夹会自动删除。 buildTypes { debug { aaptOptions { ignoreAssetsPattern '!qaa.js:!ccc.css:!bbb.t:' } }}...原创 2020-11-24 17:39:50 · 3878 阅读 · 2 评论 -
获取 Android Toolbar的真实准确高度问题
项目中设置了Toolbar代码片段如下<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="wrap_content">原创 2020-08-16 11:01:13 · 1063 阅读 · 0 评论 -
Android RadioButton 在低版本设置 android:button= @null 去除系统按钮样式失效的解决方法
Android RadioButton 在低版本设置 android:button= @null 去除系统按钮样式失效无效的解决方法具体原因参考这篇文章:https://blog.youkuaiyun.com/wl9739/article/details/53744324解决方案:在xml里同时加上 android:button="@null" app:buttonCompat = "@null"...原创 2020-03-12 10:29:29 · 961 阅读 · 0 评论