Android中Activity和Service的绑定(一)

public class BindService extends Service {



    

    private static final String TAG = "BindService";

    

    private MyBinder binder = new MyBinder();

    

    public class MyBinder extends Binder {

        

        public BindService getService () {

            

            return BindService.this;

        }

    }

    public IBinder onBind(Intent intent) {



        return binder;

    }

    

    public void MyMethod() {

        

        Log.i(TAG, "This is MyMethod()");

    }



}

 

你可能感兴趣的:(Activity)