F
focode
this problem is related to j2me environment , but threads are every
where hence i am asking it here ...
it goes like this ..
application has to check gprs connection on the mobile , this is done
in separate thread , it is implemented thing like this
public void run() {
try{
String url = "http://www.virtuosos.in/sms/gprs/pushsms_gprs_patna.php?
mobileno=000&msg=INNOLABS%20PATNAMOBILE%20DIRECTORYSEARCH%20STDBYCODE
%200612";
text = gnp.processServerResponse(url).trim(); // seperate class to
fetch url data
System.out.println("value returened = "+text);
}catch(Exception e){}
if(text.equals("error"))
{
// url_hit = "no";
switchDisplayable(null, getPacketdatamissing());
}
else
{
url_hit = "yes";
}
}
"run" method is invoked from here
public void check_gpr() {
Thread t = new Thread( this );
t.start();
if (url_hit.equals("no")) {
switchDisplayable(null, getPacketdatamissing());
} else {
switchDisplayable(null, getMainMenu());
}
}
checking gprs data takes some time , in the mean time
"switchDisplayable(null, getMainMenu());" is called , while the
process of checking gprs continues, and when the application founds
that gprs is not subscribed , it takes appropriate action , (and exits
the program ). what is required is .. until and unless the checking
of gprs is verified , the program should not take any further action ,
and should wait their itself , i think use of "wait" function should
solve my problem , can any one guied me where to put "wait" to solve
this problem, i shall be highly thankfull.
thanks and regards
Arunesh
where hence i am asking it here ...
it goes like this ..
application has to check gprs connection on the mobile , this is done
in separate thread , it is implemented thing like this
public void run() {
try{
String url = "http://www.virtuosos.in/sms/gprs/pushsms_gprs_patna.php?
mobileno=000&msg=INNOLABS%20PATNAMOBILE%20DIRECTORYSEARCH%20STDBYCODE
%200612";
text = gnp.processServerResponse(url).trim(); // seperate class to
fetch url data
System.out.println("value returened = "+text);
}catch(Exception e){}
if(text.equals("error"))
{
// url_hit = "no";
switchDisplayable(null, getPacketdatamissing());
}
else
{
url_hit = "yes";
}
}
"run" method is invoked from here
public void check_gpr() {
Thread t = new Thread( this );
t.start();
if (url_hit.equals("no")) {
switchDisplayable(null, getPacketdatamissing());
} else {
switchDisplayable(null, getMainMenu());
}
}
checking gprs data takes some time , in the mean time
"switchDisplayable(null, getMainMenu());" is called , while the
process of checking gprs continues, and when the application founds
that gprs is not subscribed , it takes appropriate action , (and exits
the program ). what is required is .. until and unless the checking
of gprs is verified , the program should not take any further action ,
and should wait their itself , i think use of "wait" function should
solve my problem , can any one guied me where to put "wait" to solve
this problem, i shall be highly thankfull.
thanks and regards
Arunesh