TabActivity안에 들어가는 ListActivity 입니다.
제생각엔 TabActivity 때문에 이러는거 같은데 다른 Activity에선 문제 없이 잘 bindserive가 되는데
이 Activity에서만 에러가 납니다ㅠㅠ 파라매터로 넘어오는 값도 바꿔고 확인해봤는데도 실행이 되지않습니다.
aidl , service 클래스 모두 이상이 없습니다 다른 activity로는 잘만되는데 이것만 이렇습니다ㅠㅠ
고수분들 답변 부탁드립니다ㅠㅠ
//////////////////////////소스/////////////////////////////////////////
public class FriendList2 extends ListActivity implements OnClickListener{
String lid;
Client client;
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.friendlist2);
Intent option = getIntent();
lid = option.getStringExtra("lid");
try {
client.Friend("Friend", lid); <============ 에러 부분
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
////////////////생략/////////////////////////////
public void onResume(){
super.onResume();
Intent intent = new Intent(getApplicationContext(), ServiceClient.class);
getApplicationContext().bindService(intent, srvConn, Context.BIND_AUTO_CREATE);
}
public void onPause(){
super.onPause();
getApplicationContext().unbindService(srvConn);
}
ServiceConnection srvConn = new ServiceConnection(){
public void onServiceDisconnected(ComponentName classname){
client = null;
}
public void onServiceConnected(ComponentName name, IBinder binder) {
client = Client.Stub.asInterface(binder);
}
};
}




시간 차이입니다.
onServiceConnected에서 client 레퍼런스 얻기 전에 onCreate에서 사용하기 때문입니다.
아마 NullPointerException이 뜰 것 같은데요.
다른 액티비티에서는 문제가 없다고 하시는데 이런 식으로 구성했을 시에는 언제든 죽을 수 있습니다.
그리고 onCreate에서 Sleep하시는데 곤란합니다. UI 쓰레드에서는 Sleep 같은 것 쓰지 마세요.