Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Method getAccessToken throws NetworkOnMainThreadException #1

Open
witoldgraca opened this issue Mar 8, 2013 · 0 comments
Open

Method getAccessToken throws NetworkOnMainThreadException #1

witoldgraca opened this issue Mar 8, 2013 · 0 comments

Comments

@witoldgraca
Copy link

03-08 12:04:39.355: WARN/System.err(8045): android.os.NetworkOnMainThreadException
03-08 12:04:39.360: WARN/System.err(8045): at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1099)
03-08 12:04:39.360: WARN/System.err(8045): at java.net.InetAddress.lookupHostByName(InetAddress.java:391)
03-08 12:04:39.365: WARN/System.err(8045): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:242)
03-08 12:04:39.365: WARN/System.err(8045): at java.net.InetAddress.getAllByName(InetAddress.java:220)
03-08 12:04:39.370: WARN/System.err(8045): at libcore.net.http.HttpConnection.<init>(HttpConnection.java:71)
03-08 12:04:39.370: WARN/System.err(8045): at libcore.net.http.HttpConnection.<init>(HttpConnection.java:50)
03-08 12:04:39.375: WARN/System.err(8045): at libcore.net.http.HttpConnection$Address.connect(HttpConnection.java:351)
03-08 12:04:39.375: WARN/System.err(8045): at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:86)
03-08 12:04:39.380: WARN/System.err(8045): at libcore.net.http.HttpConnection.connect(HttpConnection.java:128)
03-08 12:04:39.380: WARN/System.err(8045): at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:308)
03-08 12:04:39.380: WARN/System.err(8045): at libcore.net.http.HttpsURLConnectionImpl$HttpsEngine.makeSslConnection(HttpsURLConnectionImpl.java:460)
03-08 12:04:39.385: WARN/System.err(8045): at libcore.net.http.HttpsURLConnectionImpl$HttpsEngine.connect(HttpsURLConnectionImpl.java:432)
03-08 12:04:39.385: WARN/System.err(8045): at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:282)
03-08 12:04:39.390: WARN/System.err(8045): at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:232)
03-08 12:04:39.390: WARN/System.err(8045): at libcore.net.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:80)
03-08 12:04:39.395: WARN/System.err(8045): at libcore.net.http.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:188)
03-08 12:04:39.395: WARN/System.err(8045): at libcore.net.http.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:280)
03-08 12:04:39.400: WARN/System.err(8045): at org.scribe.model.Request.addBody(Request.java:120)
03-08 12:04:39.400: WARN/System.err(8045): at org.scribe.model.Request.doSend(Request.java:99)
03-08 12:04:39.405: WARN/System.err(8045): at org.scribe.model.Request.send(Request.java:63)
03-08 12:04:39.405: WARN/System.err(8045): at org.scribe.model.OAuthRequest.send(OAuthRequest.java:12)
03-08 12:04:39.405: WARN/System.err(8045): at org.scribe.oauth.NKOAuthServiceImpl.getAccessToken(NKOAuthServiceImpl.java:43)
03-08 12:04:39.410: WARN/System.err(8045): at pl.nk.android.NKExample.getAccessToken(NKExample.java:150)
03-08 12:04:39.410: WARN/System.err(8045): at pl.nk.android.NKExample.showAccessToken(NKExample.java:173)
03-08 12:04:39.415: WARN/System.err(8045): at pl.nk.android.NKExample$3.onClick(NKExample.java:76)
03-08 12:04:39.415: WARN/System.err(8045): at android.view.View.performClick(View.java:3627)
03-08 12:04:39.420: WARN/System.err(8045): at android.view.View$PerformClick.run(View.java:14329)
03-08 12:04:39.420: WARN/System.err(8045): at android.os.Handler.handleCallback(Handler.java:605)
03-08 12:04:39.420: WARN/System.err(8045): at android.os.Handler.dispatchMessage(Handler.java:92)
03-08 12:04:39.425: WARN/System.err(8045): at android.os.Looper.loop(Looper.java:137)
03-08 12:04:39.425: WARN/System.err(8045): at android.app.ActivityThread.main(ActivityThread.java:4511)
03-08 12:04:39.425: WARN/System.err(8045): at java.lang.reflect.Method.invokeNative(Native Method)
03-08 12:04:39.430: WARN/System.err(8045): at java.lang.reflect.Method.invoke(Method.java:511)
03-08 12:04:39.430: WARN/System.err(8045): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:980)
03-08 12:04:39.430: WARN/System.err(8045): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:747)
03-08 12:04:39.435: WARN/System.err(8045): at dalvik.system.NativeStart.main(Native Method)
03-08 12:04:39.435: WARN/System.err(8045): java.lang.NullPointerException
03-08 12:04:39.440: WARN/System.err(8045): at pl.nk.android.NKExample.showAccessToken(NKExample.java:173)
03-08 12:04:39.440: WARN/System.err(8045): at pl.nk.android.NKExample$3.onClick(NKExample.java:76)
03-08 12:04:39.440: WARN/System.err(8045): at android.view.View.performClick(View.java:3627)
03-08 12:04:39.440: WARN/System.err(8045): at android.view.View$PerformClick.run(View.java:14329)
03-08 12:04:39.445: WARN/System.err(8045): at android.os.Handler.handleCallback(Handler.java:605)
03-08 12:04:39.445: WARN/System.err(8045): at android.os.Handler.dispatchMessage(Handler.java:92)
03-08 12:04:39.445: WARN/System.err(8045): at android.os.Looper.loop(Looper.java:137)
03-08 12:04:39.450: WARN/System.err(8045): at android.app.ActivityThread.main(ActivityThread.java:4511)
03-08 12:04:39.460: WARN/System.err(8045): at java.lang.reflect.Method.invokeNative(Native Method)
03-08 12:04:39.460: WARN/System.err(8045): at java.lang.reflect.Method.invoke(Method.java:511)
03-08 12:04:39.465: WARN/System.err(8045): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:980)
03-08 12:04:39.465: WARN/System.err(8045): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:747)
03-08 12:04:39.465: WARN/System.err(8045): at dalvik.system.NativeStart.main(Native Method)

This makes impossible to get required access token. The same applies to makeDataRequest methods. This exception happens on API levels 11+ as described in Android documentation (http://developer.android.com/reference/android/os/NetworkOnMainThreadException.html)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant