我是android新手,作为我的学习项目,我做了一个应用程序。这是从网络服务同步数据并在我的应用程序中获取。
一切正常。
但在这种情况下
- 启动应用程序
- 检查互联网连接
- 从服务器获取内容
- 在应用程序中获取数据
5.当我们关闭移动数据/WiFi,然后按应用程序中的任何按钮突然应用程序崩溃。
有什么办法可以处理这个问题?
提前致谢
错误信息
08-14 21:28:57.670: E/AndroidRuntime(7466): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.myapp.tvc/com.myapp.tvc.SingleActivity}: java.lang.NullPointerException
08-14 21:28:57.670: E/AndroidRuntime(7466): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
08-14 21:28:57.670: E/AndroidRuntime(7466): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2122)
08-14 21:28:57.670: E/AndroidRuntime(7466): at android.app.ActivityThread.access$600(ActivityThread.java:140)
08-14 21:28:57.670: E/AndroidRuntime(7466): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1228)
08-14 21:28:57.670: E/AndroidRuntime(7466): at android.os.Handler.dispatchMessage(Handler.java:99)
08-14 21:28:57.670: E/AndroidRuntime(7466): at android.os.Looper.loop(Looper.java:137)
08-14 21:28:57.670: E/AndroidRuntime(7466): at android.app.ActivityThread.main(ActivityThread.java:4895)
08-14 21:28:57.670: E/AndroidRuntime(7466): at java.lang.reflect.Method.invokeNative(Native Method)
08-14 21:28:57.670: E/AndroidRuntime(7466): at java.lang.reflect.Method.invoke(Method.java:511)
08-14 21:28:57.670: E/AndroidRuntime(7466): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:994)
08-14 21:28:57.670: E/AndroidRuntime(7466): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:761)
08-14 21:28:57.670: E/AndroidRuntime(7466): at dalvik.system.NativeStart.main(Native Method)
08-14 21:28:57.670: E/AndroidRuntime(7466): Caused by: java.lang.NullPointerException
08-14 21:28:57.670: E/AndroidRuntime(7466): at com.myapp.tvc.SingleActivity.onCreate(SingleActivity.java:76)
08-14 21:28:57.670: E/AndroidRuntime(7466): at android.app.Activity.performCreate(Activity.java:5163)
08-14 21:28:57.670: E/AndroidRuntime(7466): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
08-14 21:28:57.670: E/AndroidRuntime(7466): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2061)
08-14 21:28:57.670: E/AndroidRuntime(7466): ... 11 more