Android的服务和内容提供商之间的区别 [英] Difference between Android Service and Content Provider

查看:216
本文介绍了Android的服务和内容提供商之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个应用程序,并得到困惑在Android的服务理念和内容提供商。在实践中,这将是他们之间的区别?

I am developing an app and get confused about the idea of Service and Content Provider in Android. In practice, what will be the difference between them?

内容提供商结果
是门面,它定义了一种应用程序之间共享数据。你很多附加本地数据库您的应用程序或创建映射到一个通用数据库内容提供商,使所有在同一台设备上的应用程序可以共享它。

Content Provider
is a facade and it defines a way to share data among applications. You many attach a local database to your app or create Content Provider mapped to a universal database so that all the application on the same device can share it.

服务结果
是需要从主要活动脱钩长时间运行的进程。它具有本地和远程服务。本地服务类的本地数据库,远程服务就像是内容提供商共享该数据库的信息。

Service
is long running processes that need to be decoupled from main activity. It has local and remote service. local service is like the local database, and remote service is like Content Provider sharing the database info.

什么我的应用程序在做什么?结果
下载信息。在后台的多个互联网资源(我想这将是服务)和存储信息。进入数据库,多个应用程序需要检索数据,格式化它们,它们输出到用户(我想这将是一个内容提供商)。

What My App is doing?
downloads info. from multiple internet resource in the background (I suppose this will be Service) and store the info. into database, and multiple applications will need to retrieve the data, format them and output them to user (I guess it will be a Content Provider).

会有什么服务和内容提供商之间的界线?新手在Android和任何建议是值得欢迎的。

What will be the fine line between Service and Content Provider? Newbie in Android, and any suggestion is welcome.

百合

推荐答案

您在服务之间的差异的理解的ContentProvider 是pretty点上。关键的一点是,的ContentProvider 只是充当检索数据的管道,而服务是为了做一些事情在没有用户交互的背景

Your understanding of the difference between a Service and ContentProvider is pretty spot on. The key thing is that a ContentProvider simply acts as a conduit for retrieving data, while a Service is meant to do something in the background without user interaction.

这篇关于Android的服务和内容提供商之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆