i'm trying to check the value of 2 strings every minute, and close the Thread when the value will be different , but this code freeze my UI. that's the code.
@Override
protected void onPostExecute(String result)
{
//Download sourcecode on String
String secondaChar = result;
//Strings declaration
String First = "";
String Second = "";
try
{
//Writing sourcecode on string
Write(secondaChar);
String ReadingFile="FileSorgente";
First=reading(ReadingFile);
while (true)
{
// Downloading new sourcecode on string
secondaChar = result.replaceAll("[^a-zA-Z]+", "");
//writing new SC on string
Scrittura(secondaChar);
// new SC on second string
Second = Reading(ReadingFile);
// check until 2 strings are the same
if(First.equalsIgnoreCase(Second))
{
Toast.makeText(getApplicationContext(), "Keep Checking", Toast.LENGTH_LONG).show();
}
else
{
Toast.makeText(getApplicationContext(), "FALSE", Toast.LENGTH_LONG).show();
break;
}
Thread.sleep(60 * 1000);
}
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (InterruptedException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
textView.setText("Usless");
}
Reading and Writing are 2 different method, i've test this in java befor and it worked, but probably in Android sdk i have to do something different.