LTT
简介
纸上得来终觉浅,绝知此事要躬行。
发布 251 篇文章
加入于 2026/02/04 17:28
Fragment 怎么切换:事务与回退栈
Fragment 切换与事务 1. FragmentTransaction 是什么 对 Fragment 的添加、移除、替换、隐藏、显示、入栈等操作,都需要通过 FragmentTransaction 完成。 常见写法: supportFragmentManager.commit {
set
- 2026/06/27 16:35
- 8
- 0
- 0
- 24.8℃
Fragment 怎么通信:不要互相强转 Activity
Fragment 通信 1. 不推荐直接互相调用 旧资料中常见写法: val activity = getActivity() as MainActivity
activity.methodA()
或者: val fragmentA = activity.supportFragmentManage
- 2026/06/27 16:35
- 9
- 0
- 0
- 24.9℃
Fragment 生命周期:自身与 View 两套
Fragment 生命周期 1. Fragment 生命周期的核心理解 Fragment 有两套相关生命周期: Fragment 自身生命周期
Fragment 的 View 生命周期
这点非常重要。Fragment 实例可能还活着,但它的 View 已经被销毁。例如: Fragment 被放入返
- 2026/06/27 16:35
- 10
- 0
- 0
- 25.0℃
Fragment 是什么:基础与加载方式
Fragment 基础与加载方式 1. Fragment 是什么 Fragment 是 Android 中用于构建可复用 UI 模块的组件。它通常表示一个界面片段,拥有自己的布局、生命周期和输入事件处理能力,但它不能独立存在,必须依附于 Activity 或另一个 Fragment。 更准确的理解是
- 2026/06/27 16:35
- 11
- 0
- 0
- 25.1℃
Service:和旧资料差在哪
Service 修订差异说明 1. 原 PDF 内容范围 原 PDF 主要包括: Service 基本概念。 Service 与 Thread 区别。 startService() 和 bindService() 两种启动方式。 Started Service 生命周期。 Bound Service
- 2026/06/27 16:35
- 11
- 0
- 0
- 25.1℃
绑定服务怎么通信:Bound Service
绑定服务与通信 1. Bound Service 是什么 Bound Service 是一种客户端-服务器模式: Client(Activity/Fragment/其他组件) 绑定 Service
Service 返回 IBinder
Client 通过 IBinder 调用 Service 的能力
- 2026/06/27 16:35
- 11
- 0
- 0
- 25.1℃
前台服务为什么必须有通知:后台限制
前台服务与后台限制 1. 为什么不能再简单说 Service 可以后台无限运行 早期 Android 资料常说: Service 可以在后台长期运行。 这个说法在现代 Android 中必须加限制条件。Android 8.0 开始,后台 Service 受到系统限制;Android 12 开始,从后
- 2026/06/27 16:35
- 13
- 0
- 0
- 25.3℃
Service 生命周期:比 Activity 简单但更容易漏
Service 生命周期 1. 生命周期路径 Service 的生命周期比 Activity 简单,但更容易出错,因为它可能在用户不可见时运行。 Service 主要有两条生命周期路径: Started Service:startService() -> onCreate() -> onStartC
- 2026/06/27 16:35
- 17
- 0
- 0
- 25.7℃
Service 是什么:基础与启动方式
1. Service 是什么 Service 是 Android 中用于执行后台或前台任务的应用组件。它没有自己的 UI,可以在用户离开某个 Activity 后继续运行某些工作。 但是要注意: Service 不是线程。
Service 默认运行在应用进程的主线程中。
Service 不会自动帮你
- 2026/06/27 16:35
- 9
- 0
- 0
- 24.9℃
ContentProvider 原理:跨进程与面试题
05、ContentProvider 原理机制与面试题 一、ContentProvider 的本质 ContentProvider 的本质是: Android 提供的一套跨进程数据访问组件
它的外层表现像数据库访问: query()
insert()
update()
delete()
但它底层
- 2026/06/27 16:12
- 10
- 0
- 0
- 25.0℃