4

I am integrating twitter posting in my app using twitter4j library. I am following this. But I am having issue in call back. After authorizing it doesn't actually comes to our app, but actually it opens up call back activity that we specified in browser. I am not sure why this is happening.

I tried to search but couldn't find anything related to this. So May be people haven't noticed or I missed something while integrating it.

Either way please help me to resolve this issue.

Community
  • 1
  • 1
keen
  • 3,001
  • 4
  • 34
  • 59
  • _I am following this_ -- There is no link here. Are you using a `WebView`? Did you setup a `WebViewClient` with `shouldOverrideUrlLoading()` so that redirections are handled by the `WebView` itself (i.e. `view.loadUrl(url)`)? – matiash Jun 15 '14 at 05:43
  • @matiash have added a link please see it again. No, I am not using WebView. – keen Jun 16 '14 at 04:55

2 Answers2

1

It's opening the custom URL link inside the browser itself because you haven't defined which activity should handle the custom links Or You haven't defined proper categories. Here is a sample. Make sure you include the categories. The android.intent.category.BROWSABLE will ensure that the browser opens your app.

    private final String CALLBACKURL = "x-oauthflow-twitter://privlyT4JCallback";

    <activity
        android:name=".TwitterLinkGrabberService"
        android:configChanges="keyboardHidden|orientation|screenSize"
        android:launchMode="singleInstance" >
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />

            <data
                android:host="privlyT4JCallback"
                android:scheme="x-oauthflow-twitter" />
        </intent-filter>
    </activity>
Shivam Verma
  • 7,973
  • 3
  • 26
  • 34
0

you already install app with same callback, you must change the callback String from manifest and call back constant from activity.try to use unique call back Address.

<data android:scheme="login-twitter" android:host="callback1" />

and

 static final String TWITTER_CALLBACK_URL = "login-twitter://callback1";
Atula
  • 2,177
  • 2
  • 12
  • 28
Mobeen Altaf
  • 138
  • 1
  • 9
  • I am doing this. Problem is it opens up this activity in browser itself. – keen Jun 17 '14 at 09:25
  • if twitter app not install activity will send intent to browser because it is mention in intent filter. – Mobeen Altaf Jun 19 '14 at 11:33
  • use android:launchMode="singleInstance" and handle in code by this way @Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); Uri uri = getIntent().getData(); if (uri != null && uri.toString().startsWith(CALLBACK_URL)) { String verifier = uri.getQueryParameter(IEXTRA_OAUTH_VERIFIER); new RetrieveAccessTokenTask().execute(verifier); } } – Mobeen Altaf Jun 19 '14 at 11:43
  • I can not have singleInstance for this activity for some other reasons. – keen Jun 19 '14 at 12:41
  • make a new A activity without GUI and start activity for result from current activity.make A singleinstance and get require data and set result.now you can receive data on current activity.May it lengthy but solve your problem.user not feel what are done.sorry for poor english – Mobeen Altaf Jun 20 '14 at 04:50
  • use this sdk https://github.com/grantland/twitter-android-sdk/tree/master/twitter/src/me/grantland/twitter – Mobeen Altaf Jun 24 '14 at 11:04