私はAndroid開発の初心者です。数日前にdoInBackground()
メソッドで解決できないというエラーが発生しました。 私のエラーは、私のコードの末尾にあるAndroid doInBackgroundエラー
e2 = e11;
createInsecureRfcommSocketToServiceRecord = null;
this.sender = e2.getMessage();
createInsecureRfcommSocketToServiceRecord.close();
でエラーが
未処理の例外がある:java.io.IO.EXCEPTION
あなたは解決策を持っている場合は、感謝しますあなたは事前に! マイコード:
protected Object doInBackground(Object[] objArr) {
BluetoothSocket createInsecureRfcommSocketToServiceRecord;
IOException e;
Throwable th;
IButton a;
Boolean valueOf;
boolean z = true;
this.jobType = (JobType) objArr[0];
this.sender = (MainActivity) objArr[1];
this.device = (BluetoothDevice) objArr[2];
try {
createInsecureRfcommSocketToServiceRecord =
device.createInsecureRfcommSocketToServiceRecord(UUID.fromString("00001101-0000-1000-8000-00805F9B34FB"));
try {
createInsecureRfcommSocketToServiceRecord.connect();
} catch (IOException e2) {
Log.e("Bluetooth", e2.getMessage());
Log.e("Bluetooth", "trying fallback");
try {
createInsecureRfcommSocketToServiceRecord = (BluetoothSocket)
this.device.getClass().getMethod("createInsecureRfcommSocket", new Class[]{Integer.TYPE}).invoke(this.device, new Object[]{Integer.valueOf(1)});
} catch (Exception e3) {
Log.e("Bluetooth", e3.getMessage());
}
try {
createInsecureRfcommSocketToServiceRecord.connect();
} catch (IOException e4) {
e2 = e4;
try {
this.error = e2.getMessage();
try {
createInsecureRfcommSocketToServiceRecord.close();
} catch (IOException e5) {
}
return null;
} catch (Throwable th2) {
th = th2;
try {
createInsecureRfcommSocketToServiceRecord.close();
} catch (IOException e6) {
}
throw th;
}
}
}
if (this.jobType == JobType.read) {
a = readDevice(createInsecureRfcommSocketToServiceRecord);
try {
createInsecureRfcommSocketToServiceRecord.close();
return a;
} catch (IOException e7) {
return a;
}
} else
if (this.jobType == JobType.stopMission) {
a = (IButton) objArr[3];
if (!(stopMission(createInsecureRfcommSocketToServiceRecord) &&
writeDevice(createInsecureRfcommSocketToServiceRecord, a))) {
z = false;
}
valueOf = Boolean.valueOf(z);
try {
createInsecureRfcommSocketToServiceRecord.close();
return valueOf;
} catch (IOException e8) {
return valueOf;
}
} else
if (this.jobType == JobType.startMission) {
boolean z2 = writeDevice(createInsecureRfcommSocketToServiceRecord, (IButton) objArr[3]) &&
startMission(createInsecureRfcommSocketToServiceRecord);
valueOf = Boolean.valueOf(z2);
try {
createInsecureRfcommSocketToServiceRecord.close();
return valueOf;
} catch (IOException e9) {
return valueOf;
}
} else {
try {
createInsecureRfcommSocketToServiceRecord.close();
} catch (IOException e10) {
}
return null;
}
} catch (IOException e11) {
e2 = e11;
createInsecureRfcommSocketToServiceRecord = null;
this.sender = e2.getMessage();
createInsecureRfcommSocketToServiceRecord.close();
return null;
} catch (Throwable th3) {
th = th3;
createInsecureRfcommSocketToServiceRecord = null;
createInsecureRfcommSocketToServiceRecord.close();
throw th;
}
return null;
}
を変更します。 – tynn