Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/365.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/219.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 应用程序在安卓系统中强制关闭_Javascript_Android_Cordova - Fatal编程技术网

Javascript 应用程序在安卓系统中强制关闭

Javascript 应用程序在安卓系统中强制关闭,javascript,android,cordova,Javascript,Android,Cordova,我已经开发了phonegap android应用程序。我一直在后台运行该应用程序,使用android服务单击按钮,并显示通知和警报。我还将使用javascript显示adsinmobi。后台进程和广告都工作正常。但突然,我在logcat中遇到错误,有时我的应用程序被强制关闭。在后台进程我正在使用web服务从服务器获取值 以下是我的Logcat错误: java.net.UnknownHostException: Host is unresolved:Mypath at java.net.Socke

我已经开发了phonegap android应用程序。我一直在后台运行该应用程序,使用android服务单击按钮,并显示通知和警报。我还将使用javascript显示adsinmobi。后台进程和广告都工作正常。但突然,我在logcat中遇到错误,有时我的应用程序被强制关闭。在后台进程我正在使用web服务从服务器获取值

以下是我的Logcat错误:

java.net.UnknownHostException: Host is unresolved:Mypath
at java.net.Socket.connect(Socket.java:1038)
at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.
<init>(HttpConnection.java:62)
at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnectionPool.
get(HttpConnectionPool.java:88)
at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.
getHTTPConnection(HttpURLConnectionImpl.java:927)
at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.
connect(HttpURLConnectionImpl.java:909)
at org.ksoap2.transport.ServiceConnectionSE.connect(ServiceConnectionSE.java:75)
at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:136)
at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:90)
at com.app.myactivity.MyService$1.handleMessage(MyService.java:123)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
at dalvik.system.NativeStart.main(Native Method)
DEBUG/AndroidRuntime(2881): Shutting down VM
WARN/dalvikvm(2881): threadid=1: thread exiting with uncaught 
exception(group=0x4001d800)
ERROR/AndroidRuntime(2881): FATAL EXCEPTION: main
ERROR/AndroidRuntime(2881): java.lang.NullPointerException
at com.app.mobilyzer.newly.MyService$1.handleMessage(MyService.java:194)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
at dalvik.system.NativeStart.main(Native Method)

请指导我。请告诉我问题出在哪里。无论是因为广告还是在后台处理。提前感谢。

我认为问题在于有时代码、网页或广告端都会出现空值。

似乎有时,您的应用程序无法连接到移动设备外部的特定URL。这就是问题所在。谢谢你的回答。好的,那么这个问题的解决方案是什么。请指导我。作为@Tarun的答案,你必须向我们展示一些代码。尝试在引发异常的代码中放置一个Try{…}catch{},并讨论为什么会发生此异常。我已经使用了Try{…}catch{}我正在检查网络连接,请给我指路