我正在尝试Android Twitter oAuth Connect 教程中的代码,并且成功运行。我试图将 twitter 授权页面更改为在 WebView 而不是 Web 浏览器中运行,但 WebView 似乎无法加载这种格式的 url,这oauth://twittersample是返回到我的应用程序的链接。成功授权后,webview 应该关闭并成功返回到我的应用程序。
有一个错误说“oauth://twittersample?oauth_token=.. 上的网页可能暂时关闭,或者它可能已永久移动到新的网址”。我该怎么办?
这是我的 onCreate 中的 WebView 的片段
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;
}
});
Run Code Online (Sandbox Code Playgroud)
这是我的 Twitter java 类TWITTER CONNECT CLASS的链接 这是我的清单
<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 …Run Code Online (Sandbox Code Playgroud) 我有一个问题,从intent扩展Fragment的类开始扩展Activity.
TabBar2.class - >扩展Activity
Favourite.class - > extends Fragment
这就是我写意图的方式.
Intent intent1 = new Intent(TabBar2.this, Favourite.class);
startActivity(intent1);
Run Code Online (Sandbox Code Playgroud)
但是当我运行intent时,我的应用程序崩溃了onClick.我的logCat说
Unable to instantiate activity
ComponentInfo{com.honey.test/com.honey.test.Favourite}:
java.lang.ClassCastException: com.honey.test.Favourite
Run Code Online (Sandbox Code Playgroud)
我做错了什么?有人可以指导我如何解决这个问题吗?