DroidForums.net is the original Verizon Android Forum! Registered Users do not see these ads. Please Register - It's Free!
Results 1 to 1 of 1

Thread: Webview with authorized Pleaes Help

  1. Droid Newbie
    askndaer's Avatar
    Member #
    163576
    Join Date
    Jan 2011
    Posts
    1
    Phone
    LG
    #1

    Webview with authorized Pleaes Help

    Hi

    I have built app that display asp pages using WebView but some of the page want the authentication (Username ,Password ) to login I want whan i press login button it will display the page after login in Webview page

    Please Help

    this is the asp page
    Welcome to UCSI eAdvantage
    This is my Code:::


    package cc.tav;

    import java.io.IOException;
    import java.io.UnsupportedEncodingException;
    import java.net.URI;
    import java.net.URISyntaxException;
    import java.util.ArrayList;
    import java.util.List;

    import org.apache.http.HttpEntity;
    import org.apache.http.HttpHost;
    import org.apache.http.HttpResponse;
    import org.apache.http.NameValuePair;
    import org.apache.http.client.ClientProtocolException;
    import org.apache.http.client.HttpClient;
    import org.apache.http.client.entity.UrlEncodedFormEntity ;
    import org.apache.http.client.methods.HttpPost;
    import org.apache.http.impl.client.DefaultHttpClient;
    import org.apache.http.message.BasicNameValuePair;
    import org.apache.http.util.EntityUtils;
    import org.apache.http.HttpHost;
    import android.app.Activity;
    import android.os.Bundle;
    import android.webkit.WebView;
    import android.webkit.WebViewClient;
    import android.widget.TextView;

    public class cc extends Activity {
    /** Called when the activity is first created. */
    WebView mWebView;
    TextView tt;

    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    String returnValue = "";

    try {
    HttpHost hh = new HttpHost("www.ucsi.edu.my");

    HttpClient httpclient = new DefaultHttpClient();

    HttpPost post = new HttpPost(new URI(
    "http://www.ucsi.edu.my/advantage/new/check_user.asp"));

    post.setHeader("Content-Type", "application/x-www-form-urlencoded");

    // Add data we're going to POST & assign data to the HttpPost
    // object.
    List<NameValuePair> nvPairs = new ArrayList<NameValuePair>(2);
    nvPairs.add(new BasicNameValuePair("txtUserID", "123456"));
    nvPairs.add(new BasicNameValuePair("txtPassword", "123456"));
    UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(nvPairs,
    "UTF-8");
    post.setEntity(formEntity);

    // Execute POST
    HttpResponse response = httpclient.execute(post);

    // Generate String from response.
    HttpEntity entity = response.getEntity();
    returnValue = EntityUtils.toString(entity);


    System.out.println(returnValue);

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

    mWebView.loadData(returnValue, "text/html/xhtml/xml",
    "gzip/deflate");

    mWebView.setWebViewClient(new WebViewClient());

    } catch (UnsupportedEncodingException e) {
    e.printStackTrace();

    } catch (ClientProtocolException e) {
    e.printStackTrace();

    } catch (IOException e) {
    e.printStackTrace();

    } catch (URISyntaxException e) {
    e.printStackTrace();

    }

    System.out.println(returnValue);
    }

    public boolean shouldOverrideUrlLoading(WebView view, String url) {
    view.loadUrl(url);
    return true;
    }
    }
  2. Sponsor
    DF Advertising
    Join Date
    Nov 2008
    Location
    DroidForums.net
     
     
     
     

Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Similar Threads

  1. webview help
    By cyberpedz in forum Android App Developers
    Replies: 1
    Last Post: 01-12-2011, 03:44 PM
  2. Authorized Retailer for Droid X ?
    By Garandhero in forum Droid X General Discussions
    Replies: 4
    Last Post: 07-19-2010, 03:54 PM

Search tags for this page

android httpclient login webview
,
android httpclient username password
,
android httpclient webview
,
android webview basic auth
,

android webview basic authentication

,

android webview httpclient

,

android webview https

,

android webview login

,
android webview post
,
android webview setheader
,
android webview windows authentication
,
webkit android httpclient
Click on a term to search our site for related topics.
Find us on Google+