[AC-6366] Titanium.Network.addEventListener ignores Mobile Data on Android Devices
GitHub Issue | n/a |
Type | Bug |
Priority | n/a |
Status | Resolved |
Resolution | Done |
Resolution Date | 2019-11-04T19:03:05.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Titanium SDK & CLI |
Labels | android, api |
Reporter | cstefaniga |
Assignee | Shak Hossain |
Created | 2019-09-12T13:59:51.000+0000 |
Updated | 2019-11-04T19:03:06.000+0000 |
Description
Reproduces also with SDK 8.1.0 GA
On Android Devices (tested on Samsung) the Titanium.Network.addEventListener responds only to WIFI changes and ignores completely the MobileData.
So for example if the MobileData is turned on and the Wifi is connected.
When closing the WIFI the Titanium.Network.online will return false even though the phone has access to internet via MobileData. If you turn On/Off the mobile data the listener does not respond at all.
Attachments
just add this code snippet to an app.js Titanium.Network.addEventListener('change', function(e){ Ti.API.error('Network system state: ' + (Titanium.Network.online ? 'ONLINE' : 'OFFLINE')); Ti.API.error('Network event state: ' + (e.online ? 'ONLINE' : 'OFFLINE') + ' on ' + e.networkTypeName); });
Hi, Yes it reproduced with 8.1.1 GA
Hello [~Claudiu Stefaniga]! We have tested this issue using the provided sample code on Samsung galaxy A7 (2018) android 9. it's working as expected on our end. *Test Environment:*
*Code:* *app.js*
*Test steps:* 1. Create a new classic project. 2. Copy the code and paste in app.js. 3. Run the project on android device. 4. After running the project, MobileData is turned on and the Wifi is connected. 5. When closing the WIFI the listener access to the internet via MobileData. 6. If you turn On/Off the mobile data the listener goes offline and online as well. *Test Output:* Please check the attachment section.
on Samsung Galaxy S7, Android 7.1 API 25 it does not work. could you please attach the app.js also ... maybe I'm doing something wrong
Hello [~Claudiu Stefaniga]! *app.js*
Thanks
OK, I think I got it. when we turn of the WIFI and the android goes to Mobile data we receive actually 2 event [ERROR] : Network system state: OFFLINE [ERROR] : Network event state: OFFLINE on NONE and very soon after we receive [ERROR] : Network system state: ONLINE [ERROR] : Network event state: ONLINE on MOBILE My problem was that in my genymotion simulator I did not receive the second event which put the network state to online on mobile. (if I use the emulators provided by Android Studio -> the events are there) And when testing on devices I actually checked the functionality (which throws and event when network changes and then consumes it in another part of the app, but that part of the app has a _debounce -> so it will ignore for 3 seconds other Network changes) thanks for the support
Hello [~Claudiu Stefaniga], the reason you don't get the second event logged in the Genymotion emulator is that the emulators always use WIFI for connectivity from the PC. Thanks.