Examine LogCat and see if you have any warnings.

Also, in case it helps, here is a sample project demonstrating the technique:

http://github.com/commonsguy/cw-android/tree/master/Service/WeatherPlus/

On Tue, Jul 27, 2010 at 10:54 PM, Jeroen Kransen <[email protected]> wrote:
> 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();

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

_Android Programming Tutorials_ Version 2.9 Available!

-- 
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