Here is my code so far, please assist me, I need a to sign into the website using post method username and password. I looked up examples online and used the wiki how to do this. I set everything inside of the button click as you see:
package com.example.work.try1;
import android.widget.Button;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.EditText;
import android.net.Uri;
import android.content.Intent;
import android.view.View;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
public class Launch extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_launch);
final View buttonS = findViewById(R.id.button);
buttonS.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Uri uri = Uri.parse("https://www.navanithiastrolife.com");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
}
});
Button b = (Button) findViewById(R.id.button2);
b.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
EditText e1 = (EditText) findViewById(R.id.editText);
String username = e1.getText().toString();
EditText e2 = (EditText) findViewById(R.id.editText3);
String password = e2.getText().toString();
OutputStream out = null;
try {
URL url = new URL("http://iconinfo.tech/mob_app/");
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.connect();
urlConnection.setRequestMethod("POST");
urlConnection.setRequestProperty("username",username);
urlConnection.setRequestProperty("password",password);
urlConnection.setDoOutput(true);
urlConnection.disconnect();
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
});
}
}
Please assist, ok thx.