[
https://issues.apache.org/jira/browse/CB-12325?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16010568#comment-16010568
]
Nico Vandenhove commented on CB-12325:
--------------------------------------
Hi Audrey So,
I'm a co-worker of Arne. It seems we jumped the gun a bit before when we said
that the issue was not recurring anymore.
There where still some users experiencing this issue. After some digging on my
part I found that the issue is related to the doze functionality of android 6+.
It seemed that when the application would come out of the doze the connection
data was not retrieved correctly. I added the following receiver to the code to
make up for this side effect.
IntentFilter intentFilterIdle = new IntentFilter();
intentFilterIdle.addAction(PowerManager.ACTION_DEVICE_IDLE_MODE_CHANGED);
if (this.receiverIdleMode == null) {
this.receiverIdleMode = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
// (The null check is for the ARM Emulator, please use
Intel Emulator for better results)
PowerManager pm =
(PowerManager)context.getSystemService(Context.POWER_SERVICE);
if(NetworkManager.this.webView != null) {
if (!pm.isDeviceIdleMode()) {
NetworkInfo info = sockMan.getActiveNetworkInfo();
if (info != null) {
if (info.isAvailable()) {
long startTime =
System.currentTimeMillis(); //fetch starting time
while(!info.isConnected()&&(System.currentTimeMillis()-startTime)<CONNECTION_TIMEOUT_CHECK)
{
info = sockMan.getActiveNetworkInfo();
}
}
}
updateConnectionInfo(info);
}
}
}
};
webView.getContext().registerReceiver(this.receiverIdleMode,
intentFilterIdle);
According to my local tests the navigator.connection.type object is now always
filled in correctly.
Kind Regards,
Nico
> navigator connection type none when connected to WiFi Android 7
> ---------------------------------------------------------------
>
> Key: CB-12325
> URL: https://issues.apache.org/jira/browse/CB-12325
> Project: Apache Cordova
> Issue Type: Bug
> Components: cordova-plugin-network-information
> Affects Versions: 6.1.1
> Environment: Android 7, Nexus 5X
> Reporter: Arne Misbaer
> Labels: triaged
>
> When resuming app after a day, the navigator.connection.type returns "none"
> even when the device has a stable wifi connection.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]