Thanks, Mark!

My code is basically the same as yours. I downloaded your project, and
guess what, that too did not work with me! I'm sure it works for you,
so I'm thinking my setup is broken somewhere.

LogCat does not mention any service being started, neither with my,
nor with your app. An error that I always get (with working apps as
well, and often more than one) is this:

07-28 11:43:12.608: ERROR/AndroidRuntime(27800): ERROR: thread attach
failed

In debug mode, I see that the Service reference remains null in both
our apps. However, I do see lots of logging related to GPS, so I think
the Service does run. I just don't get a reference to it.

I really feel lost now. It should not be this difficult to do
something this simple...

Jeroen

On 28 jul, 05:18, Mark Murphy <[email protected]> wrote:
> 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/commonsguyhttp://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