Answer the question
In order to leave comments, you need to log in
Stream not working?
In the method:
public void getSMSToSend() {
while(flag){
String sql = "http://80.252.241.43/telephony/android/get_sms.php?login=" + Account.login + "&password=" + Account.password;
String text;
synchronized (this){
MyThread mt = new MyThread(sql);
mt.start();
text = mt.returnResponce();
mt = null;
}
System.out.println("TEXT = " + text);
//String text = request(sql);
if(!text.equals("||")){
String phone = text.substring(0, text.indexOf("|"));
phoneNo = phone;
text = text.substring(text.indexOf("|")+1);
String sms = text.substring(0, text.indexOf("|"));
message = sms;
String idd = text.substring(text.indexOf("|")+1);
id=idd;
System.out.println("ID="+id);
if(!idd.equals("")&&!sms.equals("")&&!phone.equals("")) {
sendSMS();
}
}
}
MyThread mt = new MyThread(sql);
mt.start();
text = mt.returnResponce();
mt = null;
public class MyThread extends Thread {
private Thread temp;
private String responce;
private boolean flag;
MyThread(final String sql){
flag = true;
temp = new Thread(new Runnable() {
@Override
public synchronized void run() {
try {
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder().url(sql).build();
Response response = client.newCall(request).execute();
responce = response.body().string();
System.out.println("RESPONCE = " + responce);
} catch (IOException e) {
e.printStackTrace();
}
}
});
temp.start();
}
public synchronized String returnResponce() {
return responce;
}
@Override
public synchronized void start() {
super.start();
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question