Hmm...in theory it should be fine, but I'm asking myself why you need a service. For me a service is something running in the background, performing some task which could also be to keep your app up-to-date with fresh data from a server.
If I understand you correctly and you implemented your own content provider, I'd assume that you have to fetch your data from the server just at the time your content provider is being queried by some activity/service, whatever. Wouldn't that be more appropriate and resource gentle?
I don't know the initialization of an
application in android. Are the
services always already available
before the content provider is
created?
Android apps are usually designed to be modular which is also why for instance you could share an Activity of your app with other apps or actually invoke - for instance - a SMS sender activity of your Android device. Therefore there isn't a Main() somewhere as you may be accustomed in normal desktop apps, but rather you have the onCreate()
which is called by the Android OS to invoke the start of an Activity.
The only entry point I could immagine that is nearest to a Main() in desktop apps is to override Android Application class and register it appropriately in your manifest file
public class AndroidApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
}
@Override
public void onLowMemory() {
super.onLowMemory();
}
@Override
public void onTerminate() {
super.onTerminate();
}
}
and your manifest
<application android:name=".main.AndroidApplication" android:icon="@drawable/icon" android:label="@string/app_name">
...
</application>
Here you have your onCreate()
which is somehow the first method called when your app starts. But still I would pay attention in what you're going to initialize there. You should always just initialize and load those resources which you really need.