Guest User

Untitled

a guest
Jan 29th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. public class MainActivity extends AppCompatActivity {
  2. EditText login_user,login_password;
  3. Button login_button;
  4. String uName,uPwd,data;
  5. WebView webView;
  6. @Override
  7. protected void onCreate(Bundle savedInstanceState) {
  8. super.onCreate(savedInstanceState);
  9. setContentView(R.layout.activity_main);
  10. login_user=(EditText)findViewById(R.id.userName);
  11. login_password=(EditText)findViewById(R.id.passWord);
  12. login_button=(Button)findViewById(R.id.loginButton);
  13.  
  14. webView=(WebView)findViewById(R.id.webView);
  15.  
  16. login_button.setOnClickListener(new View.OnClickListener() {
  17. @Override
  18. public void onClick(View v) {
  19. try{
  20. getText();
  21.  
  22. }catch(Exception e){
  23. e.printStackTrace();
  24. }
  25. }
  26. });
  27. }
  28.  
  29. private void getText() {
  30. uName = login_user.getText().toString();
  31. uPwd = login_password.getText().toString();
  32.  
  33. WebView webview = new WebView(this);
  34. setContentView(webview);
  35. String url = "website url";
  36. String postData = null;
  37. try {
  38. postData = "username=" + URLEncoder.encode(uName, "UTF-8") + "&password=" + URLEncoder.encode(uPwd, "UTF-8");
  39. } catch (UnsupportedEncodingException e) {
  40. e.printStackTrace();
  41. }
  42. webview.postUrl(url,postData.getBytes());
  43. }
Add Comment
Please, Sign In to add comment