I am trying to connect to a page using HTTP After. I am creating an http post to create a webview. I need to redirect to another page from web view. But when the Continue button is clicked, an exception is thrown.
My code
public class ZHttpPostProjActivity extends Activity { private WebView mWebView; private ProgressDialog progressBar; private static final String TAG = "ZHttpPostProjActivity"; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.web_view); mWebView = (WebView) findViewById(R.id.webview); WebSettings webSettings = mWebView.getSettings(); webSettings.setJavaScriptEnabled(true); webSettings.setDomStorageEnabled(true); progressBar = ProgressDialog.show(ZHttpPostProjActivity.this, "", "Loading..."); postData(); } private final String URL_REGISTER = "https://www.paypal.com/checkout"; public void postData() { BufferedReader bufferedReader = null; try { List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(); nameValuePairs.add(new BasicNameValuePair("username", "username")); nameValuePairs.add(new BasicNameValuePair("password", "password")); HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost(URL_REGISTER); httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs, HTTP.UTF_8)); HttpResponse response = httpclient.execute(httppost); bufferedReader = new BufferedReader(new InputStreamReader(response .getEntity().getContent())); StringBuffer stringBuffer = new StringBuffer(""); String line = ""; String LineSeparator = System.getProperty("line.separator"); while ((line = bufferedReader.readLine()) != null) { stringBuffer.append(line + LineSeparator); } bufferedReader.close(); String webData = stringBuffer.toString(); Log.i(TAG + "web data : ", webData);
When you click Continue in a web browser, an exception is thrown
02-21 11:42:38.539: E/webviewdatabase(2848): Failed in setFormData 02-21 11:42:38.539: E/webviewdatabase(2848): java.net.MalformedURLException: Unknown protocol: about 02-21 11:42:38.539: E/webviewdatabase(2848): at java.net.URL.<init>(URL.java:288) 02-21 11:42:38.539: E/webviewdatabase(2848): at java.net.URL.<init>(URL.java:157) 02-21 11:42:38.539: E/webviewdatabase(2848): at android.webkit.WebViewDatabase.setFormData(WebViewDatabase.java:1032) 02-21 11:42:38.539: E/webviewdatabase(2848): at android.webkit.BrowserFrame.loadStarted(BrowserFrame.java:384) 02-21 11:42:38.539: E/webviewdatabase(2848): at android.webkit.JWebCoreJavaBridge.sharedTimerFired(Native Method) 02-21 11:42:38.539: E/webviewdatabase(2848): at android.webkit.JWebCoreJavaBridge.fireSharedTimer(JWebCoreJavaBridge.java:91) 02-21 11:42:38.539: E/webviewdatabase(2848): at android.webkit.JWebCoreJavaBridge.handleMessage(JWebCoreJavaBridge.java:108) 02-21 11:42:38.539: E/webviewdatabase(2848): at android.os.Handler.dispatchMessage(Handler.java:99) 02-21 11:42:38.539: E/webviewdatabase(2848): at android.os.Looper.loop(Looper.java:123) 02-21 11:42:38.539: E/webviewdatabase(2848): at android.webkit.WebViewCore$WebCoreThread.run(WebViewCore.java:673) 02-21 11:42:38.539: E/webviewdatabase(2848): at java.lang.Thread.run(Thread.java:1019) 02-21 11:42:41.324: E/cache(2848): illegal expires: Sat, Jan 01 2000 01:01:01 GMT
jennifer
source share