LoadData and loadUrl returns exected data but WebView displays it incorrect.

 private void LoadPayPal2()
 {
        WebView webContent = (WebView)findViewById(R.id.textFromPayPal);


  HttpParams httpParams1 = new BasicHttpParams();
  HttpConnectionParams.setConnectionTimeout(httpParams1, 10000);
  HttpConnectionParams.setSoTimeout(httpParams1, 10000);
  HttpClient httpClient = new DefaultHttpClient(httpParams1);



  HttpGet httpGet = new HttpGet("
https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&[email protected]&item_name=DescrOfItem&no_shipping=1&no_note=1&currency_code=USD&tax=0&lc=IL&bn=PP-DonationsBF";);

  try
  {

            webContent.getSettings().setJavaScriptEnabled(true);

webContent.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
            webContent.getSettings().setPluginsEnabled(true);
            webContent.getSettings().setSupportMultipleWindows(true);
            webContent.getSettings().setSupportZoom(true);
            webContent.getSettings().setBlockNetworkImage(false);
            webContent.getSettings().setLoadsImagesAutomatically(true);
            webContent.getSettings().setUserAgent(0);
            webContent.getSettings().setUseWideViewPort(true);
//ResponseHandler<String> responseHandler = new BasicResponseHandler();
//String responseBody = httpClient.execute(httpGet, responseHandler);
//webContent.loadData(responseBody, "text/html", "utf-8");
webContent.loadUrl("
https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&[email protected]&item_name=DescrOfItem&no_shipping=1&no_note=1&currency_code=USD&tax=0&lc=IL&bn=PP-DonationsBF
");
            SerializeString(responseBody);
  }
  catch (ClientProtocolException e)
  {
   // TODO Auto-generated catch block
   e.printStackTrace();
            webContent.loadData("<html>" + e.getMessage() + "</html>",
"text/html", "utf-8");
  }
  catch (IOException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
            webContent.loadData("<html>" + e.getMessage() + "</html>",
"text/html", "utf-8");
  }
 }

boolean SerializeString(String data)
    {
     ObjectOutputStream  objectOut = null;
     try
     {
      File file = new File("sdcard/" + "mypackage");
      if(!file.exists() && file.mkdir())
   {
       file = new File("sdcard/mypackage/test.html");
       if(!file.exists())
        file.createNewFile();
   }

      FileOutputStream stream = new
FileOutputStream("sdcard/mypackage/test.html");
      objectOut = new ObjectOutputStream(new BufferedOutputStream(stream));
      objectOut.writeChars(data);

      return true;
     }
     catch(IOException e)
     {
      e.printStackTrace();
      return false;
     }
     finally
     {
      try
      {
          if(objectOut != null)
              objectOut.close();
      }
         catch(IOException ex)
         {
          ex.printStackTrace();
          //return false;
         }
     }
    }


On Sun, Apr 19, 2009 at 9:06 PM, Evgeny V <[email protected]> wrote:

>  Will try!
> Thanks
>
>   On Sun, Apr 19, 2009 at 6:57 PM, Mattaku Betsujin <
> [email protected]> wrote:
>
>> Have you tried dumping the String that you sent to the WebView into a
>> file? Try loading that on desktop mozilla. If you still see problems there
>> that would mean your extraction code definitely has bugs.
>>
>>
>> On Sat, Apr 18, 2009 at 11:18 PM, Evgeny V <[email protected]> wrote:
>>
>>>  Thank you very much for feedback!
>>>
>>> Regarding the loop. Of course I don't do it inside a loop. The sent code
>>> is first attempt and contains this bug.
>>>
>>> Will use BasicResponseHandler to handle result. It definitely can casue
>>> the performance probpem. Do you think the way I'm extracting the resopnse
>>> string can casue the other mentioned problems?
>>> Thanks,
>>> Evgeny
>>>
>>> On Sun, Apr 19, 2009 at 6:37 AM, Chander Pechetty 
>>> <[email protected]>wrote:
>>>
>>>>
>>>>
>>>> Not sure why you are initializing one time settings of WebView in a
>>>> while loop. (and also the StringBuffer.toString inside a loop fed to
>>>> WebView)
>>>> It doesn't look right to me. Use <i>
>>>> org.apache.http.impl.client.BasicResponseHandler </i> for getting the
>>>> string from the http response  to feed it.
>>>>
>>>>
>>>>
>>>>
>>
>> >>
>>
>

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

Reply via email to