in the method buildJavaScriptData(), you should check null first. e,g. if (event == null) event = "onerror"; Otherwise, when the network is broken and recovers, your app will crash due to the NPE.