[英]The right model to manage background service and foreground “Preferences” Activity in Android
I want to write an app which is consist on two major parts: 1. BroadcastReceiver that will intercept incoming SMS messages and act on them. 我想编写一个包含两个主要部分的应用程序:1. BroadcastReceiver,它将拦截传入的SMS消息并对其进行操作。 2. Activity with GUI to manage the user preferences that will define the behavior of the broadcast receiver upon new SMS.
2.使用GUI进行活动以管理用户首选项,这些首选项将定义新SMS时广播接收器的行为。
My questions are: 我的问题是:
1 . 1。 you should use PreferenceActivity for setting and BroadcastReceiver for SMS monitoring.
您应该使用PreferenceActivity进行设置,并使用BroadcastReceiver进行SMS监视。 follow this link to use PreferenceActivity PreferenceActivity link
单击此链接以使用PreferenceActivity PreferenceActivity链接
2 . 2。 You can use SharedPreference to store your preference persistantly follow this link http://saigeethamn.blogspot.com/2009/10/shared-preferences-android-developer.html
您可以使用SharedPreference持久存储您的首选项,请访问此链接http://saigeethamn.blogspot.com/2009/10/shared-preferences-android-developer.html
3 . 3。 you don't need to start the Service here because BroadcastReceiver will go all stuff for you.
您无需在此处启动服务,因为BroadcastReceiver会帮您解决所有问题。 by the way Service can be started at Boot Time follow this link start service at boot time
顺便说一下,可以在启动时启动服务的方式在启动时遵循此链接启动服务
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.