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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T05:27:26+00:00 2026-05-21T05:27:26+00:00

i want to run the script behind the button of Google search that means…posting

  • 0

i want to run the script behind the button of Google search that means…posting a form to google server and getting the response in the form of html string and finally i put that string on webview to display result….
then i run the code …
some times it shows correct result (like someone click on google search button) but some times it shows me message to “force to close” without any changes i do in to code….that means prediction about output is unexpected…
My code is like this……

public class url extends Activity
 {
    HttpResponse end = null;
    String endResult = null;
    WebView mWebView;
    Intent myWebViewIntent;
     public static  final int TIMEOUT_MS=10000;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        HttpClient client = new DefaultHttpClient();

        HttpConnectionParams.setConnectionTimeout(client.getParams(), TIMEOUT_MS);
        HttpConnectionParams.setSoTimeout(client.getParams(), TIMEOUT_MS);
        HttpPost post = new HttpPost("http://www.google.com/m");
        List<NameValuePair> pairs = new ArrayList<NameValuePair>();
        pairs.add(new BasicNameValuePair("hl", "en"));
        pairs.add(new BasicNameValuePair("gl", "us"));
        pairs.add(new BasicNameValuePair("source", "android-launcher-widget"));
        pairs.add(new BasicNameValuePair("q", "persistent"));

        try {
            post.setEntity(new UrlEncodedFormEntity(pairs));
        /*  Uri uri = Uri.parse(post.toString());
            TextView t1=new TextView(this);
            t1.setText(post.getRequestLine().getUri());
            this.setContentView(t1);*/

        } catch (UnsupportedEncodingException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        try {
            Toast msg = Toast.makeText(url.this, "Message", Toast.LENGTH_LONG);

            msg.setGravity(Gravity.CENTER, msg.getXOffset() / 2, msg.getYOffset() / 2);

            msg.show();

            HttpResponse response = client.execute(post);

            end = response;


        } catch (ClientProtocolException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            //Toast.makeText(url.this, "problem in execute....", 20).show();
            // TODO Auto-generated catch block
            //put the balance is empty dialog box here.
            e.printStackTrace();
        }
        BasicResponseHandler myHandler = new BasicResponseHandler();
        try {

        //  Log.i("file tag","we are out of url");
            endResult = myHandler.handleResponse(end);

        } catch (HttpResponseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();

        }

    WebView engine = (WebView)findViewById(R.id.webview);
    engine.loadDataWithBaseURL(post.getRequestLine().getUri(), endResult, "text/html", "UTF-8", null);
        //engine.loadData(endResult, "text/html", "UTF-8");
        engine.requestFocus(View.FOCUS_DOWN);


         //engine.loadUrl(endResult);

    }
}

so is there any problem in emulator or installation of SDk or program itself….? becoz it seems to be the connection with the internet is done but i use the proper permission..
thank 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-05-21T05:27:27+00:00Added an answer on May 21, 2026 at 5:27 am

    The ANR you get is because you’re making a blocking call on the UI thread. To perform a blocking action without blocking the UI thread you have to use a thread and a handler, or (recommended) an AsyncTask.

    See Painless Threading.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to run a shell script on startup by google ,I found that
I have a form which on submit I want to run a script via
I want to run a php script from the command line that is always
I want to run a script every few seconds (4 or less) in google
Inside an event in my code behind file I want to run a script
I have a zsh script that I want to run such that it also
I want to run a php script on christmas that will email my family
I have a sql script file and i want to run that i can
I have created a Python script that I want to run daily via a
I wrote a Ruby script that I want to run in the background repeatedly

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.