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 9114227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:09:10+00:00 2026-06-17T04:09:10+00:00

i want to load a web page from a site and display its source

  • 0

i want to load a web page from a site and display its source on edittext , like a login , i send the login info to site and if site returns “ok” , i go to next form , but its not working , its showing emepty response :

checkout my code :

     package com.arash.rz.webtar;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

import android.os.AsyncTask;
import android.os.Bundle;
import android.app.Activity;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.impl.client.DefaultHttpClient;


public  class MainActivity extends Activity implements AsyncTaskCompleteListener<String> {

    public String SendReuqest(String command,String variables)
    {
        String response = null;
        String url="api.php?cmd="+command+"&varz="+variables;
        return response;
    }
    public void MessageBox(String message)
    {
        Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
        }  
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);



        final Button btnlogin = (Button)findViewById(R.id.button1);
        final Button btnregister = (Button)findViewById(R.id.button2);
        final EditText txtemail = (EditText)findViewById(R.id.editText1);
        final EditText txtepass = (EditText)findViewById(R.id.editText2);

        btnlogin.setFilterTouchesWhenObscured(true);

        btnlogin.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                readWebpage(v);
                }
              // Perform action on click
          }
          );


    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle item selection
        switch (item.getItemId()) {
        case R.id.menu_settings:
            finish();
            return true;
        default:
            return super.onOptionsItemSelected(item);
        }







    }
    @Override
    public void onTaskComplete(String result) {
        // TODO Auto-generated method stub

    }










     private class DownloadWebPageTask extends AsyncTask<String, Void, String> {

         @Override

         protected String doInBackground(String... urls) {

                String response = "";

                for (String url : urls) {

                      DefaultHttpClient client = new DefaultHttpClient();

                      HttpGet httpGet = new HttpGet(url);

                      try {

                             HttpResponse execute = client.execute(httpGet);

                             InputStream content =
                                          execute.getEntity().getContent();



                             BufferedReader buffer = new BufferedReader(

                                           new InputStreamReader(content));

                             String s = "";

                             while ((s = buffer.readLine()) != null) {

                                    response += s;

                             }

                      } catch (Exception e) {

                             e.printStackTrace();

                      }

                }

                return response;

         }



         protected void onPostExecute(String result) {

                //textView.setText(result);
                MessageBox("Returned:"+result);
                EditText ed = (EditText)findViewById(R.id.editText1);
                ed.setText(result);

         }

  }



  public void readWebpage(View view) {

         DownloadWebPageTask task = new DownloadWebPageTask();

         task.execute(new String[] { "http://127.0.0.1" });



  }
  • 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-17T04:09:12+00:00Added an answer on June 17, 2026 at 4:09 am

    Have you added the following line to your AndroidManifest.xml?

    <uses-permission android:name="android.permission.INTERNET" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Because I want to do things like load images from the web (see this
Hello Friends check my code http://jsfiddle.net/sUaky/2/ i want to load a web page in
I want to do a test load for a web page. I want to
I want to load a web view using loadUrl that has query params in
I have created a simple web-service using Java. i want to load jars related
I am trying to load a cron job on my web-server. I want it
I want to load up a random image while a page it is loading
I want to load data from MySql database to a HTTP form When I
I'm trying to get off site content and display it on my web site.
I need to be able to load web pages from different sites within a

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.