服务和广播接收器在Android的区别接收器、区别、Android

2023-09-05 07:39:28 作者:经住风雨我就是王

我想知道的服务和广播接收器之间的差异,任何人都可以指出,可以在机器人的移动设备可观察的一个例子。 谢谢

I want to know the difference between services and broadcast receivers, can anyone point out an example that can be observed on android mobile devices. Thanks

推荐答案

服务:如果你想做些什么的背景下,这将是在后台始终运行,即使在应用程序关闭。您可以在单独的进程中创建这个,你也可以给你的服务,其他的应用程序,如果你想。下载任何内容或音乐是很好的例子。

Service: If you want to do something in background , this will be running always in background even if the application closed. You can create this in separate process and also you can give your service to other app if you want. Downloading any content or Music is good example

广播Reciever:通常系统会发送一些信息,可以通过你的应用程序进行:收到,如果你希望,通过注册。你可以做你想要的东西时的事情发生使用的onReceive方法是什么。 示例是系统会发送BroadcastReceiver的时候新的短信息到达或引导完成

Broadcast Reciever: Usually system will send some info which can be recieved by your app if you would wish to ,by registering. And you can do something what you want when that thing happens by using onReceive method. Example is the system will send BroadcastReceiver when new sms arrives or Booting done

下面是一篇好文章:服务和BroadcastReceiver的