您好我的应用程序中我正在使用TabHost
http://ericharlow.blogspot.in/2010/09/experience-multiple-android-activities.html
现在我在webview中打开twitter标签,facebook标签页,它已成功加载但在登录时如果我在传递用户名和密码后按下登录按钮,应用程序崩溃并且跟随错误将发生。
02-28 18:58:17.519: E/AndroidRuntime(10604): android.view.WindowManager$BadTokenException: Unable to add window -- token android.app.LocalActivityManager$LocalActivityRecord@4051ec60 is not valid; is your activity running?
02-28 18:58:17.519: E/AndroidRuntime(10604): at android.view.ViewRoot.setView(ViewRoot.java:528)
02-28 18:58:17.519: E/AndroidRuntime(10604): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177)
02-28 18:58:17.519: E/AndroidRuntime(10604): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
02-28 18:58:17.519: E/AndroidRuntime(10604): at android.view.Window$LocalWindowManager.addView(Window.java:465)
02-28 18:58:17.519: E/AndroidRuntime(10604): at android.app.Dialog.show(Dialog.java:241)
02-28 18:58:17.519: E/AndroidRuntime(10604): at android.app.AlertDialog$Builder.show(AlertDialog.java:813)
02-28 18:58:17.519: E/AndroidRuntime(10604): at android.webkit.WebView.onSavePassword(WebView.java:1123)
02-28 18:58:17.519: E/AndroidRuntime(10604): at android.webkit.CallbackProxy.handleMessage(CallbackProxy.java:424)
02-28 18:58:17.519: E/AndroidRuntime(10604): at android.os.Handler.dispatchMessage(Handler.java:99)
02-28 18:58:17.519: E/AndroidRuntime(10604): at android.os.Looper.loop(Looper.java:130)
02-28 18:58:17.519: E/AndroidRuntime(10604): at android.app.ActivityThread.main(ActivityThread.java:3835)
02-28 18:58:17.519: E/AndroidRuntime(10604): at java.lang.reflect.Method.invokeNative(Native Method)
我的加载脸谱页或推特页面的课程是
public class FacebookActivity extends Activity implements OnClickListener {
private WebView mWebView;
ProgressDialog PD;
String sabNZBurl;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.facebook);
sabNZBurl = getResources().getString(R.string.fburl);
mWebView = (WebView) findViewById(R.id.webView1);
// Added by Pankit -------- start
if (!TabSample.checkForInternet.isNetworkAvailable(this, this)) {
Toast.makeText(TabSample.tabContext,
"No Net Connection... Exiting...", 2000).show();
exitOnNoNetConnection();
} else {
// Added by Pankit -------- End
PD = new ProgressDialog(TabSample.tabContext);
PD.setMessage("Please Wait......");
PD.show();
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setDomStorageEnabled(true);
mWebView.setWebViewClient(new MyWebViewClient());
mWebView.loadUrl(sabNZBurl);
}
}
final class MyWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
@Override
public void onLoadResource(WebView view, String url) {
super.onLoadResource(view, url);
}
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
PD.dismiss();
}
}