HY。我只是在我的Android应用程序中集成了Facebook SDK,我创建了一个登录。现在我想要注销,但我总是得到同样的错误。
这是我的错误:
10-23 17:24:37.510:E / AndroidRuntime(26462):致命异常:主要 10-23 17:24:37.510:E / AndroidRuntime(26462):android.os.NetworkOnMainThreadException 10-23 17:24:37.510:E / AndroidRuntime(26462):在android.os.StrictMode $ AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1099) 10-23 17:24:37.510:E / AndroidRuntime(26462):at java.net.InetAddress.lookupHostByName(InetAddress.java:391) 10-23 17:24:37.510:E / AndroidRuntime(26462):at java.net.InetAddress.getAllByNameImpl(InetAddress.java:242) 10-23 17:24:37.510:E / AndroidRuntime(26462):at java.net.InetAddress.getAllByName(InetAddress.java:220) 10-23 17:24:37.510:E / AndroidRuntime(26462):at libcore.net.http.HttpConnection。(HttpConnection.java:71) 10-23 17:24:37.510:E / AndroidRuntime(26462):at libcore.net.http.HttpConnection。(HttpConnection.java:50) 10-23 17:24:37.510:E / AndroidRuntime(26462):at libcore.net.http.HttpConnection $ Address.connect(HttpConnection.java:351) 10-23 17:24:37.510:E / AndroidRuntime(26462):at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:86) 10-23 17:24:37.510:E / AndroidRuntime(26462):at libcore.net.http.HttpConnection.connect(HttpConnection.java:128) 10-23 17:24:37.510:E / AndroidRuntime(26462):at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:308) 10-23 17:24:37.510:E / AndroidRuntime(26462):at libcore.net.http.HttpsURLConnectionImpl $ HttpsEngine.makeSslConnection(HttpsURLConnectionImpl.java:460) 10-23 17:24:37.510:E / AndroidRuntime(26462):at libcore.net.http.HttpsURLConnectionImpl $ HttpsEngine.connect(HttpsURLConnectionImpl.java:432) 10-23 17:24:37.510:E / AndroidRuntime(26462):at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:282) 10-23 17:24:37.510:E / AndroidRuntime(26462):at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:232) 10-23 17:24:37.510:E / AndroidRuntime(26462):at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:273) 10-23 17:24:37.510:E / AndroidRuntime(26462):at libcore.net.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:168) 10-23 17:24:37.510:E / AndroidRuntime(26462):at libcore.net.http.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:270) 10-23 17:24:37.510:E / AndroidRuntime(26462):at com.facebook.android.Util.openUrl(Util.java:224) 10-23 17:24:37.510:E / AndroidRuntime(26462):at com.facebook.android.Facebook.requestImpl(Facebook.java:804) 10-23 17:24:37.510:E / AndroidRuntime(26462):at com.facebook.android.Facebook.request(Facebook.java:707) 10-23 17:24:37.510:E / AndroidRuntime(26462):at com.facebook.android.Facebook.logoutImpl(Facebook.java:649) 10-23 17:24:37.510:E / AndroidRuntime(26462):at com.facebook.android.Facebook.logout(Facebook.java:642) 10-23 17:24:37.510:E / AndroidRuntime(26462):at com.example.stampp.UI.FragmentsActivity.FacebookLogout(FragmentsActivity.java:161) 10-23 17:24:37.510:E / AndroidRuntime(26462):at com.example.stampp.UI.Optionen.Account.OptionAcountFragment $ 3.onClick(OptionAcountFragment.java:120) 10-23 17:24:37.510:E / AndroidRuntime(26462):在android.view.View.performClick(View.java:3571) 10-23 17:24:37.510:E / AndroidRuntime(26462):在android.view.View $ PerformClick.run(View.java:14247) 10-23 17:24:37.510:E / AndroidRuntime(26462):在android.os.Handler.handleCallback(Handler.java:605) 10-23 17:24:37.510:E / AndroidRuntime(26462):在android.os.Handler.dispatchMessage(Handler.java:92) 10-23 17:24:37.510:E / AndroidRuntime(26462):在android.os.Looper.loop(Looper.java:137) 10-23 17:24:37.510:E / AndroidRuntime(26462):在android.app.ActivityThread.main(ActivityThread.java:4517) 10-23 17:24:37.510:E / AndroidRuntime(26462):at java.lang.reflect.Method.invokeNative(Native Method) 10-23 17:24:37.510:E / AndroidRuntime(26462):at java.lang.reflect.Method.invoke(Method.java:511) 10-23 17:24:37.510:E / AndroidRuntime(26462):at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:993) 10-23 17:24:37.510:E / AndroidRuntime(26462):at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:760) 10-23 17:24:37.510:E / AndroidRuntime(26462):at dalvik.system.NativeStart.main(Native Method)
这是我的退出代码:
public void FacebookLogout(){ 的System.out.println(facebook.getSession()isOpened()); 尝试{ facebook.logout(上下文); AppData.facebookConnect = FALSE; intent = new Intent(FragmentsActivity.this,MainActivity.class); startActivity(意向); } catch(MalformedURLException e){ // TODO自动生成的catch块 e.printStackTrace(); } catch(IOException e){ // TODO自动生成的catch块 e.printStackTrace(); }
}
有人可以帮助我吗?