Simple code example to check if there is a network conncection
Hi there,
is there someone who can expand this two lines of code with a check if there is a network connection an give out a warning if not?
Here is my simple example:
btn_03_01.addEventListener('click', function()
{
Titanium.Platform.openURL('www.appcelerator.com');
});
thank you!
2 Answers
-
Accepted Answer
try this:
btn_03_01.addEventListener('click', function() { if(Ti.Network.online){ Titanium.Platform.openURL('www.appcelerator.com'); } else { var alertDialog = Titanium.UI.createAlertDialog({ title: 'WARNING!', message: 'Your device is not online.', buttonNames: ['OK'] }); alertDialog.show(); } });
-
Hi Bruno,
You are looking for Titanium.Network.online.