Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MainActivity extends AppCompatActivity {
- EditText login_user,login_password;
- Button login_button;
- String uName,uPwd,data;
- WebView webView;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- login_user=(EditText)findViewById(R.id.userName);
- login_password=(EditText)findViewById(R.id.passWord);
- login_button=(Button)findViewById(R.id.loginButton);
- webView=(WebView)findViewById(R.id.webView);
- login_button.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- try{
- getText();
- }catch(Exception e){
- e.printStackTrace();
- }
- }
- });
- }
- private void getText() {
- uName = login_user.getText().toString();
- uPwd = login_password.getText().toString();
- WebView webview = new WebView(this);
- setContentView(webview);
- String url = "website url";
- String postData = null;
- try {
- postData = "username=" + URLEncoder.encode(uName, "UTF-8") + "&password=" + URLEncoder.encode(uPwd, "UTF-8");
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
- webview.postUrl(url,postData.getBytes());
- }
Add Comment
Please, Sign In to add comment