Advertisement
Guest User

Untitled

a guest
Dec 22nd, 2014
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. @Override
  2. protected Object doInBackground(Object... params) {
  3. String currentPassord = (String) params[0];
  4. String URL = PHPURL.url + "check_current_password.php";
  5.  
  6. try {
  7. HttpClient client = Singleton.getInstance(getActivity()).getHttpClient();
  8. HttpPost post = new HttpPost(URL);
  9.  
  10. List<NameValuePair> params1 = new ArrayList<NameValuePair>();
  11. params1.add(new BasicNameValuePair("currentPassord", currentPassord));
  12.  
  13. UrlEncodedFormEntity ent = new UrlEncodedFormEntity(params1,HTTP.UTF_8);
  14. post.setEntity(ent);
  15.  
  16. HttpResponse responsePOST = client.execute(post);
  17. HttpEntity resEntity = responsePOST.getEntity();
  18.  
  19. if (resEntity != null) {
  20. String result = EntityUtils.toString(resEntity);
  21. JSONArray jarr = new JSONArray(result);
  22.  
  23. for(int i =0 ; i < jarr.length(); i++){
  24.  
  25. JSONObject jobj = jarr.getJSONObject(i);
  26. session_state = jobj.getString("session");
  27. if(session_state.equals("success")){
  28. check_pw = jobj.getString("check_pw");
  29. }
  30. }
  31. }
  32. } catch (Exception e) {
  33. Log.d("EXCEPTION", "ERROR IS " + e.getMessage());
  34. e.printStackTrace();
  35. }
  36. return null;
  37. }
  38.  
  39. private Singleton(Context context){
  40. this.context = context;
  41. client = new DefaultHttpClient();
  42. manager = new Manager();
  43. }
  44.  
  45. public static Singleton getInstance(Context c){
  46. if(uniqueInstance == null){
  47. synchronized (Singleton.class) {
  48. if(uniqueInstance == null){
  49. uniqueInstance = new Singleton(c.getApplicationContext());
  50. }
  51. }
  52. }
  53. return uniqueInstance;
  54. }
  55.  
  56. public HttpClient getHttpClient(){
  57. return client;
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement