Please how can I pass the contents of my android form data to a webpage and this data is displayed on the webpage.
In essence, when I click on the "ok" button of my android form data, I want the webpage to be opened with those data being displayed.
Thanks.
I am opening the webpage using the code snippet below
public void onClick(View v) {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://10.0.2.2/test/confirmPayment.php"));
new MyAsyncTask().execute(ntwk);
startActivity(browserIntent);
}
I'm trying to pass the form data using the code below.
public class MyAsyncTask extends AsyncTask<String, Integer, Double>{
@Override
protected Double doInBackground(String... params) {
// TODO Auto-generated method stub
postData(params[0]);
return null;
}
protected void onPostExecute(Double result){
//pb.setVisibility(View.GONE);
Toast.makeText(getApplicationContext(), "command sent", Toast.LENGTH_LONG).show();
}
private Context getApplicationContext() {
// TODO Auto-generated method stub
return null;
}
public void postData(String valueIWantToSend) {
// Create a new HttpClient and Post Header
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://10.0.2.2/test/confirmPayment.php");
try {
// Add your data
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("names", valueIWantToSend));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
// Execute HTTP Post Request
HttpResponse response = httpclient.execute(httppost);
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
} catch (IOException e) {
// TODO Auto-generated catch block
}
}
}
The problem is that the webpage opens but the form data isn't passed. Please help. Thanks.