Executing the function calls in onServiceConnected() method is not
what is wanted as described in following case:
------------------------
CODE SNIPPET
------------------------
class ServiceWrapperClass
{
private ISomeServiceInterface myService
......
private ServiceConnection progressBarServiceConn = new
ServiceConnection() {
@Override
public void onServiceConnected(ComponentName name,
IBinder service)
{
myService =
ISomeServiceInterface.Stub.asInterface(service);
}
@Override
public void onServiceDisconnected(ComponentName name)
{
myService = null;
}
};
public void onCreate(Bundle savedInstanceState) {
....................
//create intent to connect to service
Intent serviceIntent = new Intent("some.uri");
bindService(serviceIntent, progressBarServiceConn,
Context.BIND_AUTO_CREATE);
//access the service
Integer someValue = myService.someFunc(1, 2); //
NullPointerException here - How to make sure service should be
running
before any function is called on the service ?
}
On Jul 21, 3:16 pm, Mark Murphy <[email protected]> wrote:
> On Thu, Jul 21, 2011 at 1:26 AM, animeshsi <[email protected]> wrote:
> > The issue is that I need to call the service methods as soon as it is
> > connected.
> > So, Is there any way by which I can execute the functions of service
> > JUST AFTER binding is complete ?
>
> Execute those "functions" in onServiceConnected().
>
> --
> Mark Murphy (a Commons
> Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy
>
> Android Training in London:http://bit.ly/smand1,http://bit.ly/smand2
--
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