Hey, Guys
I'm having some problems to do a While statement to block my app. In my case, in the begin of the code, I check if the internet is active and if not I do a While to block 'while' the internet not return:
I tried this two ways:
while (Titanium.Network.networkType == Titanium.Network.NETWORK_NONE){ }
and
if(!Titanium.Network.online){}
Is there something missing from my code? Thanks.
1 Answer
Using a while statement like this assumes that you will be looping over something until a certain criteria is met, at which point you will execute some other code, but the while loop in this case is only checked on the first run.
If you have no network, and you want to execute some function or code when you get the network back, you should listen for the network change event. When the change event is fired, check to see if the network matches your criteria, then execute the necessary code.
Your Answer
Think you can help? Login to answer this question!