Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

Issue with network detection change

$
0
0

Hi,

I'm actually getting an issue with the current code in my alloy app. Here is the part of the code :

console.log(Ti.Network.networkType);
console.log(Ti.Network.online);
console.log(Ti.Network.networkTypeName);
 
Ti.Network.addEventListener('change', function(e) {
  console.log(e.networkType);
  console.log(e.online);
  console.log(e.networkTypeName);
  if(e.networkType != Titanium.Network.NETWORK_NONE) {
    if(!Alloy.Globals.isLoggedIn) {
      Alloy.createController('connexion').getView().open();
    }
  }
});
On the launch of the app (on a device where the airplane mode is on). The logs give me this :
[INFO]  0
[INFO]  false
[INFO]  NONE
 
[INFO]  2
[INFO]  true
[INFO]  MOBILE
The first logs outside of the addEventListener, give me the right answer. But the logs inside give me a wrong answer ! And of course I need this evenListener for my app :/ I don't want to do a setInterval, because it will unnecessarily use the device ressources.

Is this a known bug ? Thanks for the reply.

PS: some info :

  • Application type : mobile
  • Titanium SDK : 4.1.0.GA
  • Platform & version : Android (OxygenOs) 5.0
  • Device : OnePlus One

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>