你好,我有一个小聊天应用程序,绑定到我的服务创建一个与我的服务器的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