Мое приложение падает только на смартфоне с android 10 ... не на смартфоне с android 9 Почему?
Это моя ошибка:
Поток [7, tid = 8537, WaitingInMainSignalCatcherL oop, Поток * = 0x70f8fa2c00, peer = 0x131c0378, «Улавливатель сигналов»]: реагирует на сигнал 3
Написал следы стека для захоронения
Метод onCreate (NetActivity. java):
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
NetClient task = new NetClient();
payload = task.execute(ip, String.valueOf(Global.config_device), Global.uid, network.getSSID(), password, friendlyName).get();
}
}
});
Мой AsyncTask (NetClient. java):
public class NetClient extends AsyncTask<String, Void, String> {
Socket socket = null;
PrintWriter out = null;
BufferedReader buffer = null;
String ip;
int port = 8899;
String response = "";
int errors = 0;
private String[] conn_errors = {"", String.valueOf(R.string.error_provision), "Error: socket close...", "Error: receiving message...", "Unknown error...", "Error disconnecting socket..."};
protected Boolean connect() {
boolean res = false;
try {
if (socket == null) {
socket = new Socket(ip, port);
if (socket.isConnected()) {
res = true;
}
out = new PrintWriter(socket.getOutputStream());
buffer = new BufferedReader(new InputStreamReader(socket.getInputStream()));
}
} catch (IOException e) {
Log.e("ERROR connect", e.getMessage());
errors = 1;
}
return res;
}
protected void disConnect() {
if (socket != null) {
if (socket.isConnected()) {
try {
out.close();
socket.close();
} catch (IOException e) {
e.printStackTrace();
errors = 5;
}
}
}
}
protected void sendData(String message) {
if (message != null) {
out.write(message);
out.flush();
}
}
protected String receiveData() {
try {
String message = "";
message = buffer.readLine();
message += buffer.readLine();
message += buffer.readLine();
message += buffer.readLine();
message += buffer.readLine();
return message;
} catch (IOException e) {
errors = 3;
return "Error receiving response: " + e.getMessage();
}
}
@Override
protected String doInBackground(String... params) {
boolean conn;
ip = params[0];
String message = "Teste sample" ;
try {
conn = connect();
Log.w("NetClient", "" + conn);
if (conn) {
sendData(message);
} else {
errors = 2;
}
if (conn) {
response = receiveData();
} else {
errors = 2;
}
} catch (Exception e) {
Log.w("NetClient", "Exception");
e.printStackTrace();
errors = 4;
} finally {
disConnect();
Log.i("NetClient", "Finished");
return response;
}
return String.valueOf(errors);
}
protected void onProgressUpdate(Integer... progress) {
Log.w("onProgressUpdate", "Progress: " + progress[0]);
}
protected void onPostExecute(String result) {
if (errors == 0) {
Log.i("onPostExecute", "Payload [" + result.length() + "] : " + result);
}
if (errors > 0) {
Log.i("ERROR", conn_errors[errors]);
}
}
}