Hi all! I'm trying to get PayPal web page with requested donation parameters. It works within IE or Firefox.
Can anyone advise whether I'm running some wrong code? Layout main.xml: --------------------- <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/ android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <WebView android:id="@+id/viewFromPayPal" android:layout_width="fill_parent" android:layout_height="fill_parent" /> </LinearLayout> --------------------- Java code: --------------------- public class DonationTestView extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); LoadPayPal(); } private void LoadPayPal() { WebView webContent = (WebView)findViewById (R.id.viewFromPayPal); HttpParams httpParams1 = new BasicHttpParams(); HttpConnectionParams.setConnectionTimeout(httpParams1, 10000); HttpConnectionParams.setSoTimeout(httpParams1, 10000); HttpClient httpClient = new DefaultHttpClient(httpParams1); HttpParams httpParams2 = new BasicHttpParams(); httpParams2.setParameter("cmd", "_xclick"); httpParams2.setParameter("business", "my_em...@address.com"); httpParams2.setParameter("item_name", "Descr"); httpParams2.setParameter("no_shipping", "1"); httpParams2.setParameter("no_note", "1"); httpParams2.setParameter("currency_code", "USD"); httpParams2.setParameter("tax", "0"); httpParams2.setParameter("lc", "IL"); httpParams2.setParameter("bn", "PP-DonationsBF"); HttpPost httpPost = new HttpPost("https://www.paypal.com/cgi-bin/ webscr"); try { HttpResponse response = httpClient.execute(httpPost); httpPost.setParams(httpParams2); HttpEntity entity = response.getEntity(); StringBuilder sb = new StringBuilder(); if (entity != null) { BufferedReader reader = null; try { reader = new BufferedReader( new InputStreamReader(entity.getContent())); try { while(true) { String res = reader.readLine(); if(res.equals(0)) { 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().setUseWideViewPort (true); webContent.loadData(sb.toString(), "text/ html", "utf-8"); break; } Log.i("WEB", res); sb.append(res); } } catch (Exception e) { webContent.loadData("<html>" + e.getMessage() + "</html>", "text/html", "utf-8"); return; } } catch (IOException ex) { throw ex; } catch (RuntimeException ex) { httpPost.abort(); throw ex; } finally { if(reader != null) reader.close(); } } } 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"); } } } --------------------- --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---