How to instantiate android service with a constructor?

Service extends Context, so you don't really need it as a parameter in your constructor, since you can use that same instance.

If you have any other parameters that you would like to pass in to the service, i would recommend adding them to the startService intent as extras and getting them in the service.onStartCommand method.


You should not construct services (or activities, or broadcast receivers) explicitly. The Android system does that internally. The proper way to construct a service is via startService() with an intent; feel free to add extra parameters to that intent.

EDIT: or bindService(). Then you have options - either build a custom interface with AIDL, or use raw transact().