I want to use a local service to fence off some logic in a singleton
class. From my Activities I try to bind to it. The method
bindService() returns true, but the Service onCreate() is never
called, nor is the ServiceConnector's onServiceConnected().

Please tell me what part I am missing.

Here is my manifest snippet (note that I do not set :remote, as I want
the service to be local):

<service android:enabled="true"
android:name=".service.ConsumptionService"/>

This is how I call the ServiceConnector and the Service:

                Intent serviceIntent = new Intent(this, 
ConsumptionService.class);
                ConsumptionServiceConnection serviceConnection = new
ConsumptionServiceConnection();
                boolean isBound = bindService(serviceIntent, serviceConnection,
Context.BIND_AUTO_CREATE);

Especially the "BIND_AUTO_CREATE" part should to the creation,
according to the documentation.

This is the Service itself:

        @Override
    public void onCreate() {
                super.onCreate();
                measurementDao = new MeasurementDaoImpl(this);
                calculator = new TrendCalculatorImpl(measurementDao);
        }

        @Override
        public IBinder onBind(Intent intent) {
                return binder;
        }

        public class LocalBinder extends Binder {
        ConsumptionService getService() {
            return ConsumptionService.this;
        }
    }

        private final IBinder binder = new LocalBinder();

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to