Hello,

I am working on an android application, where the activity binds to a
local service to perform certain tasks.

Now I am binding the service in the OnCreate method of the Activity,
after which the activity has to use the service object to invoke the
functionality defined in the servicein the OnStart method. The problem
here is that once a call "bindservice" has been made, we might not get
the serviceobject immediately, so my service object would be null till
that time. So i cannot invoke the service functions.

So is there a way to determine in the activity that the service has
been bound and the service object is valid and could be used now. For
reference i'm attaching a code snippet for the same.

@Override
    public void onCreate(Bundle savedInstanceState)
    {
        Intent mServiceIntent ;
        super.onCreate(savedInstanceState);
        setContentView(R.layout.retrieve_guide_data);
                bindService(new Intent(UIMain.this,
                                          CxService.class),
mConnection, Context.BIND_AUTO_CREATE);

    }

@Override
protected void onStart()
{
        super.onStart();
        System.out.println("----In OnStart of Activity---");

        if(mBoundService != null)
        {
                int status = mBoundService.authenticate("9876543210");
                                if(status == 200)
                {
                        AuthFunc();
                }
                }
}

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

Reply via email to