Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2014
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. class LoggingTask extends AsyncTask<String, String, String> {
  2.  
  3. @Override
  4. protected String doInBackground(String...nothing) {
  5. UserFunctions userFunctions = new UserFunctions();
  6. JSONObject json = userFunctions.loginUser(KEY_USERNAME, KEY_PASSWORD);
  7. return "";
  8.  
  9.  
  10. @Override
  11. protected void onPostExecute(String result) {
  12. try {
  13. if (!KEY_USERNAME.equals("") && !KEY_PASSWORD.equals("")) {
  14. loginErrorMsg.setText("Incorrect USername or Password");
  15.  
  16. //String res = json.getString(KEY_SUCCESS);
  17. String res = json.getString(KEY_SUCCESS);
  18. if(Integer.parseInt(res) ==1){
  19. DatabaseHandler db = new DatabaseHandler (getApplicationContext());
  20. JSONObject json_user = json.getJSONObject("user");
  21.  
  22.  
  23. btnLogin.setOnClickListener(new View.OnClickListener() {
  24.  
  25.  
  26. public void onClick(View argo) {
  27.  
  28. // Launch Dashboard Screen
  29. Intent dashboard = new Intent(getApplicationContext(), DashboardActivity.class);
  30.  
  31. // Close all views before launching Dashboard
  32. dashboard.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
  33.  
  34. startActivity(dashboard);
  35. finish();
  36.  
  37. }
  38. });
  39.  
  40. }else{
  41. //Error in Login
  42. loginErrorMsg.setText("Incorrect username/password");
  43. }
  44. }
  45.  
  46. }catch (JSONException e) {
  47. e.printStackTrace();
  48. }
  49. }
  50. }
  51. }
  52. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement