开发者

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 mess开发者_开发技巧ages and act on them. 2. Activity with GUI to manage the user preferences that will define the behavior of the broadcast receiver upon new SMS.

My questions are:

  1. What is the right model in general to achieve my goal? am i right in my assumption that i should use an activity for the "Preferences" and BroadcastReciever for the underlying service?
  2. How can save the user's preferences persistently (like in a file or something) and make them also accessible for the service to read them?
  3. How do i make it that the service will be launched at the device's startup?


1 . you should use PreferenceActivity for setting and BroadcastReceiver for SMS monitoring. follow this link to use PreferenceActivity PreferenceActivity link

2 . You can use SharedPreference to store your preference persistantly follow this link http://saigeethamn.blogspot.com/2009/10/shared-preferences-android-developer.html

3 . you don't need to start the Service here because BroadcastReceiver will go all stuff for you. by the way Service can be started at Boot Time follow this link start service at boot time

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜