Reputation: 13
There are 2 textboxes, ed1
and ed2
in main activity and a save button.
final EditText ed1 = (EditText)findViewById(R.id.location_address);
final EditText ed2 = (EditText)findViewById(R.id.workername);
public void postData() {
String fullUrl = "https://docs.google.com/forms/d/e/1FAIpQLSe5WZB-e95xrx3ZbwiOWtJx3wEuT-fJw/formResponse";
HttpRequest mReq = new HttpRequest();
String data = "entry.748835646=" + URLEncoder.encode(location) + "&" +
"entry.481985278=" + URLEncoder.encode(name);
String response = mReq.sendPost(fullUrl, data);
Log.i(myTag, response);
}
I'm not getting what to write for the 2 edittexts above String data.
How to write code for ed1
and ed2
, such that after the user enters ed1
and ed1
, then clicking on save button, the data gets saved to Google Form? (that is the postData
method gets executed)
Upvotes: 0
Views: 202
Reputation: 13
I solved it myself:
The modified postData() method is as follows:-
public void postData() {
String fullUrl = "https://docs.google.com/forms/d/e/1FAIpQLSe5WZbIwv6m5uqf2Z73Uh7B-e95xrx3ZbEuT-fJw/formResponse";
HttpRequest mReq = new HttpRequest();
final EditText ed1 = (EditText)findViewById(R.id.location_address);
final EditText ed2 = (EditText)findViewById(R.id.workername);
location=ed1.getText().toString();
name=ed2.getText().toString();
String data = "entry.748835646=" + URLEncoder.encode(location) + "&" +
"entry.481985278=" + URLEncoder.encode(name);
String response = mReq.sendPost(fullUrl, data);
Log.i(myTag, response);
}
Upvotes: 0
Reputation: 971
public void postData() {
String fullUrl = "https://docs.google.com/forms/d/e/1FAIpQLSe5WZB-e95xrx3ZbwiOWtJx3wEuT-fJw/formResponse";
HttpRequest mReq = new HttpRequest();
String data = "entry.748835646=" + URLEncoder.encode(ed1.getText().toString()) + "&" +
"entry.481985278=" + URLEncoder.encode(ed2.getText().toString());
String response = mReq.sendPost(fullUrl, data);
Log.i(myTag, response);
}
Upvotes: 1