0

こんにちは私のアプリでは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)

FacebookページまたはTwitterページをロードするための私のクラスは

    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();
    }
}
4

0 に答える 0