[ https://issues.apache.org/jira/browse/CB-6907?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14028739#comment-14028739 ]
ASF GitHub Bot commented on CB-6907: ------------------------------------ Github user clelland commented on the pull request: https://github.com/apache/cordova-plugin-network-information/pull/10#issuecomment-45822792 Hi Dozer, I just found this as well -- I filed [CB-6907](https://issues.apache.org/jira/browse/CB-6907) and fixed it yesterday ([diff](https://git-wip-us.apache.org/repos/asf?p=cordova-plugin-network-information.git;a=blobdiff;f=src/android/NetworkManager.java;h=aa4e16120d48e834cf97f9b8422c5d2df8b35c49;hp=4c54b81c4f8413b88d0a884ddea044f2d65fae05;hb=a5e9631;hpb=f4ffab9c71c767d31c2e1157303ba98a40446a16)) (with almost exactly your fix :) ) Feel free to close this PR (And thanks for letting us know!) > Application crashes immediately on startup if no network is available > --------------------------------------------------------------------- > > Key: CB-6907 > URL: https://issues.apache.org/jira/browse/CB-6907 > Project: Apache Cordova > Issue Type: Bug > Components: Android, Plugin Network Information > Reporter: Ian Clelland > Assignee: Ian Clelland > Priority: Critical > > Working on the App harness, I've found that the application will crash > immediately if there is no network available (No 3G, no Wi-Fi) at startup > time. > From the Android docs, {{NetworkManager.getActiveNetworkInfo}} "Returns > a NetworkInfo object for the current default network or null if no network > default network is currently active" > [http://developer.android.com/reference/android/net/ConnectivityManager.html#getActiveNetworkInfo()] > This results in an NPE at NetworkManager.java:201. > {code:title=Stack trace} > E/AndroidRuntime(31166): java.lang.RuntimeException: Error receiving > broadcast Intent { act=android.net.conn.CONNECTIVITY_CHANGE flg=0x4000010 > (has extras) } in > org.apache.cordova.networkinformation.NetworkManager$1@41ea6600 > E/AndroidRuntime(31166): at > android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:769) > E/AndroidRuntime(31166): at > android.os.Handler.handleCallback(Handler.java:733) > E/AndroidRuntime(31166): at > android.os.Handler.dispatchMessage(Handler.java:95) > E/AndroidRuntime(31166): at android.os.Looper.loop(Looper.java:136) > E/AndroidRuntime(31166): at > android.app.ActivityThread.main(ActivityThread.java:5001) > E/AndroidRuntime(31166): at java.lang.reflect.Method.invokeNative(Native > Method) > E/AndroidRuntime(31166): at > java.lang.reflect.Method.invoke(Method.java:515) > E/AndroidRuntime(31166): at > com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785) > E/AndroidRuntime(31166): at > com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601) > E/AndroidRuntime(31166): at dalvik.system.NativeStart.main(Native Method) > E/AndroidRuntime(31166): Caused by: java.lang.NullPointerException > E/AndroidRuntime(31166): at > org.apache.cordova.networkinformation.NetworkManager.getConnectionInfo(NetworkManager.java:201) > E/AndroidRuntime(31166): at > org.apache.cordova.networkinformation.NetworkManager.updateConnectionInfo(NetworkManager.java:171) > E/AndroidRuntime(31166): at > org.apache.cordova.networkinformation.NetworkManager.access$000(NetworkManager.java:38) > E/AndroidRuntime(31166): at > org.apache.cordova.networkinformation.NetworkManager$1.onReceive(NetworkManager.java:110) > E/AndroidRuntime(31166): at > android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:759) > E/AndroidRuntime(31166): ... 9 more > {code} -- This message was sent by Atlassian JIRA (v6.2#6252)