Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8190055
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T03:29:29+00:00 2026-06-07T03:29:29+00:00

Hello Stackoverflowers! I have written a relatively simple application that consists of a login

  • 0

Hello Stackoverflowers!

I have written a relatively simple application that consists of a login text field, a password text field and a login button.

My goal is that when the user enters the login information and touches the login button, the application will log the user into the website I have specified and open it up in a different intent or WebView. My current implementation opens a new activity with a WebView and passes in the login information. My code is as follows for the new activity:

setContentView(R.layout.web);


    try {
        //add the users login information(username/pw) to a List
        List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
        nameValuePairs.add(new BasicNameValuePair("email", "random@gmail.com"));
        nameValuePairs.add(new BasicNameValuePair("password", "password1"));

        //declare a new HttpClient
        HttpClient httpclient = new DefaultHttpClient();

        //set the HttpPost to the desire URL
        HttpPost httppost = new HttpPost(URL_STRING);

        //set the entity to a new UrlEncodedForm with the login info and type
        httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs, HTTP.UTF_8));

        //store the response
        HttpResponse response = httpclient.execute(httppost);

        //get the data from the response
        String data = new BasicResponseHandler().handleResponse(response);            

        //get the webview from the xml
        WebView webview = (WebView)findViewById(R.id.webView);

        webview.setWebViewClient(new WebViewClient() {  
            @Override  
            public boolean shouldOverrideUrlLoading(WebView view, String url)  
            {  
                view.loadUrl(url);  
                return true;  
            }  
        }); 

        //load the return website from the server
        webview.loadDataWithBaseURL(httppost.getURI().toString(), data, "text/html", HTTP.UTF_8, null);

This successfully logs me in to the URL (an https site) and opens the page, however if you try to click on any of the buttons on the website it takes you back to the login page in the WebView, and it does not display many of the attributes on the website (charts/graphs).

Could this be a cookie thing?

So is there a way to send the login info via a new intent? Or is there a solution to my WebView implementation?

(here is a relatively similar(ish) question that never got a definitive answer Android SSO (Single sign-on) for app)

Thank you for your time! I really appreciate you taking a look at my question.

EDIT: So giseks’s solution worked for me to get the webpage to stay within the WebView, however the charts/graphs/etc on the page still did not display, the solution for that was as simple as enabling javascript for the WebSettings

webview.getSettings().setJavaScriptEnabled(true);

Here’s Google’s WebSettings Android API for reference: WebSettings

This helped me, I hope it helps you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T03:29:31+00:00Added an answer on June 7, 2026 at 3:29 am

    My guess is that your application doesn’t handle cookies right. Take a look at this question, it may help.

    WebView and Cookies on Android

    EDIT

    In your code you seem to pass only the html retrieved from request to the WebView. Cookies seem to get lost somewhere. I’d suggest you another approach.

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    
        WebView webv = (WebView)findViewById(R.id.MainActivity_webview);         
        webv.setWebViewClient(new WebViewClient(){
                @Override
                public boolean shouldOverrideUrlLoading(WebView view, String url) {
                    view.loadUrl(url);
                    return true;
                }
        });
    
        String postData = FIELD_NAME_LOGIN + "=" + LOGIN +
                "&" + FIELD_NAME_PASSWD + "=" + PASSWD;
    
        // this line logs you in and you stay logged in
        // I suppose it works this way because in this case WebView handles cookies itself
        webv.postUrl(URL, EncodingUtils.getBytes(postData, "utf-8"));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello StackOverflow'ers, I have a (flex) app that, on the click of a button,
Hello stackoverflowers! This is my button: <Button android:layout_width=fill_parent android:layout_height=0dp android:layout_weight=0.30 android:text=@string/menu_button_newgame android:id=@+id/button_newgame /> when
Hello Fellow stackoverflowers, I´m stuck writing a piece of code. I have application with
Hello fellow StackOverflowers. I'm have a brain fart right now, and I cannot seem
Hello stack overflowers, I have a desing that uses the flyweight pattern to share
Hello I have this problem with PyQt4-dev-tools that include: * a user interface compiler
Hello guys i have set background image on my input text and text area
Hello all in my iphone application after sending login xml request am getting following
Hello we have an SQL server application running over a low bandwith connection. We
Hello Stackoverflowers! I created a simple sqlite DB like so. //event table name private

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.