Android - bindService at fragment -


I have an activity class and on this onResume section I used the next code - @ Override Protected Zero (Regenerate) {super.onResume (); Bind service (new intent (main activity., IMS service class), connection, context. }

on onPause I used the next code -

  place the protected zeros on @Override () {unbindService (mConnection); super.onPause (); }   

As you can understand that I am compulsive and engaged in any service.

The thing is now that I want to use the piece instead of the activity.

To do this, I have changed this paraguse code to -

  Prevent protected zeros on @override () {getActivity () UnbindService (mConnection); super.onPause (); }   

And it feels good.

But the thing with which I have a problem is the bind part on onResume , I have tried the next code -

  @ Override protected Resume at zero () {super.onResume (); Bind service (new intent (getActivity (), IMService.class), mConnection, Context.BIND_AUTO_CREATE); }   

But Eclipse tells me an error -

  The method is mandatory for bindService (intent, service connection, difference) type MainFragment   

The service is looking like this -

  & lt; Service Android: name = "com.example.test.services.IMService" & gt; & Lt; / Services & gt;   

Why can not I bind this section? Maybe I need to get something? GetActivity Code

Thnks for any assistance

Thanks to Raghunandan - this is the solution -

  getActivity (). BindService (new intent (getActivity (), IMService.class), mConnection, Context.BIND_AUTO_CREATE);    

use

  getActivity.bindService (parameter )   

it needs

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -