简体   繁体   English

Android MVP架构中如何分离Service和Activity?

[英]How to separate Service and Activity in Android MVP architecture?

I am working on Android Music-Player.我正在开发 Android 音乐播放器。 I am using Service to play songs, SQLite Database to store songs, and ContentProvider to access sqlite database.我使用Service播放歌曲,使用SQLite 数据库存储歌曲,使用ContentProvider访问 sqlite 数据库。 I am confused, how can I maintain connection between service and activity?我很困惑,如何在服务和活动之间保持联系? Should I implement connection between presenter and Service?我应该在presenter和Service之间实现连接吗? As I am planning to consider my Service as Model, what will be the best and easiest approach to do that?当我计划将我的服务视为模型时,最好和最简单的方法是什么?

看看这里描述的方法 - 它应该可以帮助您在 MVP 架构中将您的服务与您的活动分离。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 主持人是否应该了解Android MVP架构中的“活动”? - Should the Presenter know about the Activity in Android MVP architecture? 具有MVP的Android架构组件 - Android architecture components with MVP Android MVP用于复杂活动 - Android MVP for complex activity Android MVP和Lifecycle体系结构组件 - Android MVP and Lifecycle architecture component 如何在Android中使用图像时实现适当的MVP架构? - How to implement proper MVP architecture whilst using images in Android? 如何在Android中的MVP架构中的两位演示者之间共享数据? - How to share data between two presenters in MVP architecture in Android? Android MVP-Architecture如何使用SQLiteHelper在模型中进行数据库调用 - Android MVP-Architecture How to make Database Calls in the Model with SQLiteHelper 如何测试在Android MVP Clean Architecture中注入存储库中的sharedpreference - How to test sharedpreference that inject in repository in Android MVP Clean Architecture 如何使用 MVP 架构将数据添加到 android 中的 Firestore? - How to add data to Firestore in android using MVP Architecture? Android MVP体系结构和领域-如何避免在MVP层之间传递上下文? - Android MVP Architecture and Realm - How to Avoid Passing Context among the MVP layers?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM