你好,我有一個小聊天應用程序,綁定到我的服務創建一個與我的服務器的TCP/IP連接。 我使用aidl btw。Android unbindService
我的問題是,我不知道要處理屏幕方向,特別是在銷燬方法。
我希望我的服務始終處於在線狀態,並且我不想在應用程序破壞時停止它。
現在我已經對「onDestroy」方法unbindService(conn)解決了「泄漏連接問題」。
當活動被重新創建後被凍結。 謝謝,這裏有一些代碼片段。
serviceIntent = new Intent(getApplicationContext(),ChatService.class);
boolean result = bindService(serviceIntent, conn,Context.BIND_AUTO_CREATE);
startService(new Intent(getApplicationContext(),ChatService.class));
Log.d(TAG, "Service binded");
@Override
protected void onDestroy() {
Log.d(TAG, "ON DESTROY");
unbindService(conn);
super.onDestroy();
}
Thak你,這工作:android:configChanges =「orientation」 – Catalin 2012-08-18 22:13:27