Return to Snippet

Revision: 39839
at January 21, 2011 16:20 by askndaer


Initial Code
i have built app that display asp pages using WebView but some of the page want the authentication (Username ,Password ) to login I want my application to auto login to this page using Username and Password from my Application

This is my code Please Help

public class eadvantage extends Activity {
    /** Called when the activity is first created. */
WebView mWebView; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.eadvantage);

     HttpClient httpclient = new DefaultHttpClient();
     HttpPost httppost = new HttpPost("http://www.ucsi.edu.my/advantage/new/main.asp");

    try {
        // Add your data
        List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
        nameValuePairs.add(new BasicNameValuePair("txtUserID", "12345));
        nameValuePairs.add(new BasicNameValuePair("txtPassword", "12345"));
        httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

        // Execute HTTP Post Request
        HttpResponse response = httpclient.execute(httppost);

        mWebView = (WebView) findViewById(R.id.webview);
        mWebView.getSettings().setJavaScriptEnabled(true);
        mWebView.loadUrl("http://www.ucsi.edu.my/advantage/new/main.asp");


        mWebView.setWebViewClient(new WebViewClient());

Initial URL

                                

Initial Description

                                

Initial Title
Android WebView login on Android ((plz help)

Initial Tags

                                

Initial Language
Java