hi...
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 to code....that means prediction about execution
is not guaranteed.
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));

                } catch (UnsupportedEncodingException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }
                try {
                        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.requestFocus(View.FOCUS_DOWN);

    }
}




so ,is there in problem in emulator or installation of  SDK or problem
in program it self......

thank you....

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to