0

I developed an Android Service without GUI, called via a custom Intent by external applications. The previous version of the software used a GUI and preference management was done via a graphical menu that opened a PreferenceActivity.

However, now I would like to have a dedicated preference screen, only for service configuration. I'm wondering if it is possible to reuse the PreferenceActivity, via having an icon on the launcher saying "MyApp Preferences" or by having a "Settings" button on the services list (for example, see Google Keyboard on the running services).

If possible, I would like to achieve this by not creating another activity, since I have nothing useful to put on that besides a single button to open settings. Any ideas?

Krupa Patel
  • 3,309
  • 3
  • 23
  • 28
André
  • 323
  • 4
  • 18
  • Have you tried making a single preferenceactivity and giving that activity the intent filters for MAIN and LAUNCHER? – EpicPandaForce Jun 19 '14 at 13:32
  • It works. I tried once with just the intent filter launcher, but nothing happened. However this activity is not exactly the "main" activity. For example, when I launch the project via Eclipse, it shouldn't start immediately. Do you know any configuration to prevent this? – André Jun 19 '14 at 13:43
  • Hmm... maybe this can help? http://stackoverflow.com/questions/10909683/launch-android-application-without-main-activity-and-start-service-on-launching – EpicPandaForce Jun 19 '14 at 13:45
  • Thinking better, maybe prefer as is right now. When the user install the app for first time, the preferences screen show up and allow some sort of initial configuration. Thanks Zhuinden! If you put your comment on an answer, I will gladly accept it, since it solves the problem. – André Jun 19 '14 at 13:51

1 Answers1

0

I think you can use the PreferenceActivity as the entry point, and don't need your own activity with a single button to launch it. For that, add

        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>

To your PreferenceActivity in the AndroidManifest.xml.

EpicPandaForce
  • 79,669
  • 27
  • 256
  • 428