私はSDK 10(2.3.3)でコンパイルしています:受け入れる前にBluetoothサーバーソケットをキャンセルすると、プロセス全体が終了します。どうして?
android:minSdkVersion="10"
android:targetSdkVersion="16"
私は2台のソニーエリクソンのスマートフォンでテストしています。 OneにはAndroid 2.3.7と4.0.1があります。
私はlistenUsingInsecureRfcommWithServiceRecord
を使用して、Bluetoothで新しいサーバーソケットを開き、接続を待ち受けます。
接続が正常に受け入れられれば、すべて正常に動作します。私もサーバーソケットをキャンセルしようとすることができますが、それはちょうど作成された接続ソケットを気にしていないようです。
しかし、bluetoothServerSocket.close();
行が実行されるとすぐに接続を受け入れる前にサーバーソケットを取り消したい場合、アクティビティ全体が閉じられ、プロセスが終了します。さらに、これはで、私が扱うことができる通常の例外ではありません。
実際には、logcat自体も終了します!そして、私はすぐにあなたが下記を参照することができ、エラーをつかむために、再びそれを実行する必要があります。
Zygote D Process 25471 terminated by signal (11)
295 InputDispatcher W channel '2c2e20a8 com.pligor.test/activities.MainActivity (server)' ~ Consumer closed input channel or an error occurred. events=0x8
295 InputDispatcher E channel '2c2e20a8 com.pligor.test/activities.MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
295 dalvikvm D GC_FOR_ALLOC freed 1299K, 21% free 13252K/16583K, paused 93ms
295 InputDispatcher W Attempted to unregister already unregistered input channel '2c2e20a8 com.pligor.test/activities.MainActivity (server)'
295 BluetoothService D Tracked app 25471 diedType:10
295 BluetoothService D Removing service record 10009 for pid 25471
132 SurfaceFlinger D Release buffer at 0x61c08
295 WindowManager I WINDOW DIED Window{2c2e20a8 com.pligor.test/activities.MainActivity paused=false}
295 ActivityManager I Process com.pligor.test (pid 25471) has died.
295 ActivityManager W Force removing ActivityRecord{2c021800 com.pligor.test/activities.MainActivity}: app died, no saved state
295 WindowManager W Failed looking up window
295 WindowManager W java.lang.IllegalArgumentException: Requested window [email protected] does not exist
295 WindowManager W at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:7165)
295 WindowManager W at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:7156)
295 WindowManager W at com.android.server.wm.WindowState$DeathRecipient.binderDied(WindowState.java:1545)
295 WindowManager W at android.os.BinderProxy.sendDeathNotice(Binder.java:417)
295 WindowManager W at dalvik.system.NativeStart.run(Native Method)
295 WindowManager I WIN DEATH: null
295 BluetoothEventLoop D Property Changed: UUIDs : 11
295 hAdapterStateMachine D BluetoothOn process message: 51
295 InputManagerService W Got RemoteException sending setActive(false) notification to pid 25471 uid 10040
注:信号(11)で終了したプロセスは、セグメンテーションフォールト(http://en.wikipedia.org/wiki/SIGSEGV)を意味します。
try {
isCancelled = true;
bluetoothServerSocket.close();
} catch {
case e: IOException => throw new NotClosedException;
}
:
private val bluetoothServerSocket: BluetoothServerSocket = try {
bluetoothAdapter.listenUsingInsecureRfcommWithServiceRecord(MY_SERVICE_NAME_INSECURE, MY_UUID_INSECURE);
}
catch {
case e: IOException => throw new ServerSocketException;
}
は私がソケットのBluetoothを閉じるには、このコードを使用します。EDIT
は、私は次のコード(Scala
)を使用してのBluetoothサーバソケットを作成します
上記のように主な問題は解決され、その信号が(11)の終端は、彼らがアクセスすべきではないか、それが存在していないメモリをアクセスするプログラムによって引き起こされるようです。あなたのプログラムが過度のメモリを使用する理由はわかりませんが、どれくらい使っているのかチェックしたいかもしれません。コードの投稿は、ここでトラブルシューティングを行う際に役立ちます。 – hBrent
私は問題がないことを確認します。しかし、コードのどの部分を正確に追加したいのですか? –
'bluetoothServerSocket.close();を呼び出すと、接続が確立されていないときに例外がスローされますか? – Houf