What is the error here at this line? And how to use callback url of twitter and in android? What is the difference between the two?

android
oauth

#1

What is the error here at this line?

RequestToken requestToken = twitter.getOAuthRequestToken();

It gives error log like this:

FATAL EXCEPTION: main
Process: vt.parthvora.smi, PID: 29529
android.os.NetworkOnMainThreadException
at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1145)
at java.net.InetAddress.lookupHostByName(InetAddress.java:385)
at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236)
at java.net.InetAddress.getAllByName(InetAddress.java:214)
at com.android.okhttp.internal.Dns$1.getAllByName(Dns.java:28)
at com.android.okhttp.internal.http.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:216)
at com.android.okhttp.internal.http.RouteSelector.next(RouteSelector.java:122)
at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:292)
at com.android.okhttp.internal.http.HttpEngine.sendSocketRequest(HttpEngine.java:255)
at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:206)
at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:345)
at com.android.okhttp.internal.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:89)
at com.android.okhttp.internal.http.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:197)
at com.android.okhttp.internal.http.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:254)
at twitter4j.HttpClientImpl.handleRequest(HttpClientImpl.java:137)
at twitter4j.HttpClientBase.request(HttpClientBase.java:57)
at twitter4j.HttpClientBase.post(HttpClientBase.java:86)
at twitter4j.auth.OAuthAuthorization.getOAuthRequestToken(OAuthAuthorization.java:115)
at twitter4j.auth.OAuthAuthorization.getOAuthRequestToken(OAuthAuthorization.java:92)
at twitter4j.TwitterBaseImpl.getOAuthRequestToken(TwitterBaseImpl.java:292)
at twitter4j.TwitterBaseImpl.getOAuthRequestToken(TwitterBaseImpl.java:287)
**at vt.parthvora.smi.MainActivityFragment.loginToTwitter(MainActivityFragment.java:292)**
**at vt.parthvora.smi.MainActivityFragment.access$700(MainActivityFragment.java:49)**
**at vt.parthvora.smi.MainActivityFragment$5.onClick(MainActivityFragment.java:177)**
at android.view.View.performClick(View.java:4497)
at android.view.View$PerformClick.run(View.java:18590)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5021)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:827)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:643)
at dalvik.system.NativeStart.main(Native Method)

What is the use of callback url in android?
and how to use it?

Any help would be much appreciable…


#2

@parthvora25 Can you provide more context about what you’re looking to do? One line of code and an error message isn’t quite enough to help out. So please provide more info and I’ll dig in with you :smile:
-Mike


#3

Hello Sir,
Thanks for the reply but the issue is solved now but would like to know what is a callback url and does it work?
Thanks for the help.


#4

Here is a good explanation of a callback URL. How to set this up for Fabric to use is explained here.


#5

Thank you for the links.


#6