Advertisement
Guest User

Untitled

a guest
Sep 5th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.58 KB | None | 0 0
  1. class getlogindetails extends AsyncTask<String,String,String>
  2. {
  3. protected void onPreExecute()
  4. {
  5. super.onPreExecute();
  6. pdialog=new ProgressDialog(loginactivity.this);
  7. pdialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
  8. pdialog.setMessage("Logging in. Please wait...");
  9. pdialog.setIndeterminate(false);
  10. pdialog.setCancelable(true);
  11. pdialog.show();
  12. }
  13. @Override
  14. protected String doInBackground(String... params)
  15. {
  16. int success;
  17. try
  18. {
  19. Uri.Builder builder=new Uri.Builder()
  20. .appendQueryParameter("username",username)
  21. .appendQueryParameter("password",password);
  22. String query=builder.build().getEncodedQuery();
  23. JSONObject json=jsonParser.makeHttpRequest(urllogin,query);
  24. if(json!=null)
  25. {
  26. success=json.getInt("result");
  27. if(success==1)
  28. {
  29. Intent menuintent=new Intent(getApplicationContext(),menuactivity.class);
  30. startActivity(menuintent);
  31. }
  32. else
  33. {
  34. loginactivity.this.runOnUiThread(new Runnable() {
  35. @Override
  36. public void run() {
  37. tmsg.setText("User not found !");
  38. tmsg.setTextColor(Color.RED);
  39. }
  40. });
  41. }
  42. }
  43. else
  44. {
  45. loginactivity.this.runOnUiThread(new Runnable() {
  46. @Override
  47. public void run() {
  48. tmsg.setText("Unable to contact server !");
  49. tmsg.setTextColor(Color.RED);
  50. }
  51. });
  52. }
  53. }
  54. catch(JSONException e)
  55. {
  56. e.printStackTrace();
  57. }
  58. return null;
  59. }
  60. protected void onPostExecute(String s)
  61. {
  62. pdialog.dismiss();
  63. }
  64. }
  65.  
  66.  
  67.  
  68.  
  69.  
  70. username=tusername.getText().toString();
  71. password=tpassword.getText().toString();
  72. urllogin="http://10.3.5.59/iverson/loginprocess.php";
  73. new getlogindetails().execute();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement