I was trying out codes from Android Twitter oAuth Connect Tutorial and it worked successfully. I tried to change the twitter authorization page to run in a WebView instead of a web browser but the WebView couldn’t seem to load url with this format oauth://twittersample which is the link back to my application. Upon successful authorization, the webview should close and return to my app successfully.
There is an error saying “The web page at oauth://twittersample?oauth_token=…. might be temporarily down or it may have moved permanently to a new web address”. What should I do?
This is the snippet to my WebView that is in my onCreate
WebView myWebView = (WebView)findViewById(R.id.myWebView);
myWebView.setWebViewClient(new WebViewClient()
{
@Override
public boolean shouldOverrideUrlLoading(WebView webView, String url)
{
if (url != null && url.startsWith("oauth://twittersample"))
//handleTwitterCallback(url);
{
System.out.println("TWEET TWEET TWEET");
webView.loadUrl(url);
return true;
}
else
return false;
}
});
This is the link to my Twitter java class TWITTER CONNECT CLASS
And this is my manifest
<activity android:name="com.test.settings.ShareSettings" android:label="ShareSettings" android:screenOrientation="portrait" android:configChanges="orientation|keyboardHidden">
<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:scheme="oauth" android:host="twittersample"/>
</intent-filter>
</activity>
Attached is the logcat when successfully run in browser

I finally get it to work. I think earlier it did not work because I did not retrieve access token into the WebView.
In my WebView under onCreate i did this
and in my retrieveAccessToken(url) i have this.
I got this to work exactly how I wanted it and logged in successfully.
Do correct me if I’m doing anything wrong here.
Thank you @user1690588 and @Nikolay Elenkov, for your time to help me out. 🙂