Reputation: 2198
I have an Android App that is a service: it runs in the background invisibly to the user. This is accomplished as follows:
MainActivity
starts up an IntentService
, and then immediately finishesIntentService
.android:Theme.Translucent.NoTitleBar
.This works beautifully!
However, I would like to offer the user the possibility to change some settings. This can not be achieved in the usual manner (Preferences
) because we have no UI.
I am now considering creating a Custom Account Type for the App. After all, in this manner change settings via the systems Settings App (icon: cog).
However, this is a bit of a hack.
Custom Account
s are for Apps that require Authentication on a server. That does not apply.I wonder:
Custom Account Types
is considered a good idea?Upvotes: 1
Views: 153
Reputation: 361
Create an Ongoing (sticky) notification which launches settings activity upon interaction.
Upvotes: 1
Reputation: 1006664
we ship hundreds of these devices with one single Google Account
I would expect that Google would be unhappy with your plan.
How other developers have managed changing setting for a service?
Options include:
Not having MainActivity
finish()
immediately, but instead offer settings right there, or via a separate activity accessible from there
Having a separate launcher icon for your settings activity
If your service is a foreground service, have an action on its Notification
that leads to your settings activity
If your minSdkVersion
is 24 or higher, give your settings activity the following <intent-filter>
, so the user can click over to your settings activity from a gear icon on your app's screen in the Settings app:
<intent-filter>
<action android:name="android.intent.action.APPLICATION_PREFERENCES" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
If Custom Account Types is considered a good idea?
Only if it is an actual account, one that the user would understand. So, in your case, based on your description, this is not a good idea IMHO.
Upvotes: 2