1
我得到的,各國的應用程序無法破壞活動從JMDNSService.java無法摧毀Android的活動
private JMDNSService jmdnsService = null;
@Override
public void onDestroy() {
super.onDestroy();
jmdnsService = null; // destroy this object so we don't keep polling.
if (D) {Log.i(TAG, "++++ ON DESTROY +++++"); }
try {
stopJMDNS();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
stopWifi();
}
private void stopWifi() {
WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
wifi.setWifiEnabled(false);
}
private void stopJMDNS() throws IOException {
jmdnsService.shutDownJmDNS();
}
代碼錯誤:
public boolean shutDownJmDNS(){
if(jmdns != null){
try {
jmdns.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return false;
}
return true;
}
return false;
}
下面是從該logcat的輸出它正在生產:
01-11 19:19:54.528: E/AndroidRuntime(754): FATAL EXCEPTION: main
01-11 19:19:54.528: E/AndroidRuntime(754): java.lang.RuntimeException: Unable to destroy activity {com.whooznear.android/com.whooznear.android.WhoozNearActivity}: java.lang.NullPointerException
01-11 19:19:54.528: E/AndroidRuntime(754): at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:2950)
01-11 19:19:54.528: E/AndroidRuntime(754): at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:2968)
01-11 19:19:54.528: E/AndroidRuntime(754): at android.app.ActivityThread.access$1100(ActivityThread.java:122)
01-11 19:19:54.528: E/AndroidRuntime(754): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1057)
01-11 19:19:54.528: E/AndroidRuntime(754): at android.os.Handler.dispatchMessage(Handler.java:99)
01-11 19:19:54.528: E/AndroidRuntime(754): at android.os.Looper.loop(Looper.java:132)
01-11 19:19:54.528: E/AndroidRuntime(754): at android.app.ActivityThread.main(ActivityThread.java:4123)
01-11 19:19:54.528: E/AndroidRuntime(754): at java.lang.reflect.Method.invokeNative(Native Method)
01-11 19:19:54.528: E/AndroidRuntime(754): at java.lang.reflect.Method.invoke(Method.java:491)
01-11 19:19:54.528: E/AndroidRuntime(754): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
01-11 19:19:54.528: E/AndroidRuntime(754): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
01-11 19:19:54.528: E/AndroidRuntime(754): at dalvik.system.NativeStart.main(Native Method)
01-11 19:19:54.528: E/AndroidRuntime(754): Caused by: java.lang.NullPointerException
01-11 19:19:54.528: E/AndroidRuntime(754): at com.whooznear.android.WhoozNearActivity.stopJMDNS(WhoozNearActivity.java:488)
01-11 19:19:54.528: E/AndroidRuntime(754): at com.whooznear.android.WhoozNearActivity.onDestroy(WhoozNearActivity.java:447)
01-11 19:19:54.528: E/AndroidRuntime(754): at android.app.Activity.performDestroy(Activity.java:4561)
01-11 19:19:54.528: E/AndroidRuntime(754): at android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1078)
01-11 19:19:54.528: E/AndroidRuntime(754): at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:2937)
01-11 19:19:54.528: E/AndroidRuntime(754): ... 11 more
由於某種原因,它不會讓我摧毀我的活動?任何想法都會有所幫助。