Here i initialize get the value of user input after btnlog onclick
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
usernameField = (EditText) findViewById(R.id.etUname);
passwordField = (EditText) findViewById(R.id.etUpass);
btnlog = (Button) findViewById(R.id.loginbtn);
btnview = (Button) findViewById(R.id.viewbtn);
reglink = (TextView) findViewById(R.id.reglink);
btnlog.setOnClickListener (new View.OnClickListener(){
@Override
public void onClick(View v){
String u = usernameField.getText().toString();
String p = passwordField.getText().toString();
new loginPost().execute();
}
});
Now i want to received the user input from public class and encode it, and the variable u and p is basically doesnt getting any value from public class
@Override
protected String doInBackground(String... params) {
try{
String str = "username=" + u + "&password=" + p;
String data = URLEncoder.encode("str", "UTF-8") + "=" +
URLEncoder.encode(str, "UTF-8");
strUrl ="http://10.0.2.2/android/login.php?"+data+"";
Log.d("STR", data);
URL url = new URL (strUrl);
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("POST");
con.connect();