Social networking sites's login is happening via own Application
<p>I have a activity in which a Dialog box opens showing list of Social network icons. Clicking on the icon, it will open the site in the same app rather than browser but problem is there when we hit login after entering username and password, it shows exception as follow:</p>

<pre><code>12-27 14:16:14.062: E/AndroidRuntime(4052): FATAL EXCEPTION: main
12-27 14:16:14.062: E/AndroidRuntime(4052): android.view.WindowManager$BadTokenException: Unable to add window -- token android.app.LocalActivityManager$LocalActivityRecord@41c59680 is not valid; is your activity running?
12-27 14:16:14.062: E/AndroidRuntime(4052):     at android.view.ViewRootImpl.setView(ViewRootImpl.java:513)
12-27 14:16:14.062: E/AndroidRuntime(4052):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:301)
12-27 14:16:14.062: E/AndroidRuntime(4052):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:215)
12-27 14:16:14.062: E/AndroidRuntime(4052):     at android.view.WindowManagerImpl$CompatModeWrapper.addView(WindowManagerImpl.java:140)
12-27 14:16:14.062: E/AndroidRuntime(4052):     at android.view.Window$LocalWindowManager.addView(Window.java:537)
12-27 14:16:14.062: E/AndroidRuntime(4052):     at android.app.Dialog.show(Dialog.java:278)
12-27 14:16:14.062: E/AndroidRuntime(4052):     at android.app.AlertDialog$Builder.show(AlertDialog.java:932)
12-27 14:16:14.062: E/AndroidRuntime(4052):     at android.webkit.WebView.onSavePassword(WebView.java:1402)
12-27 14:16:14.062: E/AndroidRuntime(4052):     at android.webkit.CallbackProxy.handleMessage(CallbackProxy.java:442)
12-27 14:16:14.062: E/AndroidRuntime(4052):     at android.os.Handler.dispatchMessage(Handler.java:99)
12-27 14:16:14.062: E/AndroidRuntime(4052):     at android.os.Looper.loop(Looper.java:137)
12-27 14:16:14.062: E/AndroidRuntime(4052):     at android.app.ActivityThread.main(ActivityThread.java:4424)
12-27 14:16:14.062: E/AndroidRuntime(4052):     at java.lang.reflect.Method.invokeNative(Native Method)
12-27 14:16:14.062: E/AndroidRuntime(4052):     at java.lang.reflect.Method.invoke(Method.java:511)
12-27 14:16:14.062: E/AndroidRuntime(4052):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
12-27 14:16:14.062: E/AndroidRuntime(4052):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
12-27 14:16:14.062: E/AndroidRuntime(4052):     at dalvik.system.NativeStart.main(Native Method)
12-27 14:16:14.605: I/dalvikvm(4052): threadid=3: reacting to signal 3
12-27 14:16:14.613: I/dalvikvm(4052): Wrote stack traces to '/data/anr/traces.txt'
12-27 14:16:16.273: I/Process(4052): Sending signal. PID: 4052 SIG: 9
</code></pre>

<p>and here is my code:</p>

<pre><code>public class ShareActivity extends Activity implements OnItemClickListener {
    //public static ShareActivity context;
    WebView wv;
    boolean land_scape=false;
    ProgressDialog pdlg;
    String links[]= new String[]{"Facebook","Twitter","Google Plus","Pintrest"};
    ListView lv1;
    Dialog dialog ;
    @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        int currentOrientation = getResources().getConfiguration().orientation;
        if (currentOrientation == Configuration.ORIENTATION_LANDSCAPE) {
           setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
           land_scape=true;

        }
        else {
           setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
           land_scape=false;
        }
      setContentView(R.layout.share_layout);    
      //context=this;

      wv=(WebView)findViewById(R.id.webView1);
      wv.getSettings().setJavaScriptEnabled(true);
      dialog = new Dialog(ShareActivity.this.getParent());
      dialog.setTitle("Please select");

      dialog.setCanceledOnTouchOutside(false);
      dialog.setContentView(R.layout.share_list);
      lv1=(ListView)dialog.findViewById(R.id.listShare);
      lv1.setAdapter(new CustomShareAdapter(this,links));
      lv1.setOnItemClickListener(this);
      dialog.show();


    }

    @Override
    public void onItemClick(AdapterView&lt;?&gt; arg0, View arg1, int arg2, long arg3) {

        switch(arg2)
        {
        case 0:  
            wv.loadUrl("http://www.facebook.com");
            break;
        case 1: 
            wv.loadUrl("https://mobile.twitter.com/login");
            break;

        case 2: 
            wv.loadUrl("http://www.plus.google.com");       
            break;
        case 3: 
            wv.loadUrl("http://www.pinterest.com");         
            break;
        }
        wv.setWebViewClient(new WebViewClient());
        dialog.dismiss();
    }


    @Override
     public void onResume()
     {

            //Determine screen size
            if ((getResources().getConfiguration().screenLayout &amp;      Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE) {     
                //Toast.makeText(this, "Large screen set to landscape",Toast.LENGTH_LONG).show();
                setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
                land_scape=true;


            }
            else if ((getResources().getConfiguration().screenLayout &amp;      Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_NORMAL) {     
                //Toast.makeText(this, "Normal sized screen set to portrait" , Toast.LENGTH_LONG).show();
                setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
                land_scape=false;

            } 
            else if ((getResources().getConfiguration().screenLayout &amp;      Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_SMALL) {     
               // Toast.makeText(this, "Small sized screen set to portrait " , Toast.LENGTH_LONG).show();
                setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
                land_scape=false;
            }
            else {
                //Toast.makeText(this, "Screen size is neither large, normal or small" , Toast.LENGTH_LONG).show();
                land_scape=false;
            }
            super.onResume();
     }
    @Override
    public void onBackPressed() {
        Intent backIntent = new Intent(this, MainActivity.class);
        startActivity(backIntent);
        super.onBackPressed();
    }

}
</code></pre>

<p>2nd QUestion: it also shows empty screen which i have not set. 
I have searched alot on this regard. Please help me.</p>
