ServiceConnection 을 별도의 파일로 구현하여 TabActivity를 상속받은 클래스에서
버튼 클릭시 서비스를 Bind시켰습니다.
bindservice 리턴값을 확인 결과 true 값이 넘어옵니다.
문제는 onServiceConnected 가 호출되지 않습니다.
package com.Mytest.SmartDown;
public class RemoteMobileNetworkConnection implements ServiceConnection
{
private IMobileNetworkService remoteService = null;
public void onServiceConnected(ComponentName name, IBinder service)
{
Log.d( getClass().getSimpleName(), "onServiceConnected()" );
remoteService = IMobileNetworkService.Stub.asInterface((IBinder)service);
}
public void onServiceDisconnected(ComponentName name)
{
Log.d( getClass().getSimpleName(), "onServiceDisconnected" );
remoteService = null;
}
public void TESTAAA() throws RemoteException
{
if(remoteService != null)
remoteService.TEST();
}
}
TabActivity를 상속 받은 클래스에서 아래와 같이 bindservice를 호출하였습니다.
public void onClick(View view)
{
switch(view.getId())
{
case R.id.btnSearch:
{
private ServiceConnection remoteServiceConnection = new RemoteMobileNetworkConnection();
Intent ServiceIntent = new Intent();
ServiceIntent.setComponent(new ComponentName("com.Mytest", "com.Mytest.MobileNetworkService"));
ServiceIntent.setAction("com.Mytest.TestService");
boolean bResult = bindService(ServiceIntent, remoteServiceConnection, Context.BIND_AUTO_CREATE);
if(true == bResult)
mTextResult.setText("bindService 성공");
else
mTextResult.setText("bindService 실패");
}
}
}