文章目录
- 1. 使用Intent传递消息
- 2. 使用全局单例类(Singleton)
- 3. 使用静态变量
- 4. 使用Application全局静态变量
- 5. 使用 Android系统剪切板(Clipboard)
- 6. 本地化存储方式
- 6.1 使用SharedPreferences
- 6.2 使用File文件存储方式传递消息
- 6.3 使用SQLite数据库方式传递消息
 
- 7. 使用广播(Broadcast)
- 7.1 广播(Broadcast)和本地广播(LocalBroadcast)的区别
- 7.2 使用本地广播(LocalBroadcast)
 
- 8. 使用EventBus或者LiveDataBus
- 8.1 使用EventBus示例:
- 8.2 使用LiveDataBus示例:
- 8.3 注意事项:
 
 
在
Android开发中,如果 
Activity A需要向 
Activity C传递消息,但 
Activity A不能直接跳转到 
Activity C(即没有直接的 
Activity跳转路径),可以考虑以下几种方法: 
 
1. 使用Intent传递消息
- 当A启动B时,可以通过Intent将消息放入Intent的Extra中。
- B在接收到消息后,可以将这个消息再次放入新的- Intent的- Extra中,并启动- C时携带这个- Intent。
- 这样,消息就可以通过Intent在A、B、C之间传递。
示例代码如下:
在Activity A中启动Activity B并传递消息:
// 在Activity A中
Intent intent = new In