Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.pc_szerviz;
- import java.io.IOException;
- import org.apache.commons.httpclient.HttpClient;
- import org.apache.commons.httpclient.methods.GetMethod;
- import android.content.Context;
- import android.os.AsyncTask;
- public class ConnectionTask extends AsyncTask<String, Void, String> {
- HttpClient client;
- GetMethod getMethod;
- String response;
- @Override
- protected String doInBackground(String... commands) {
- client = new HttpClient();
- getMethod = new GetMethod(commands[0]);
- response = new String();
- try {
- client.executeMethod(getMethod);
- response = getMethod.getResponseBodyAsString();
- getMethod.releaseConnection();
- } catch(IOException e) {
- e.printStackTrace();
- }
- return response;
- }
- }
- //Így van meghívva
- public boolean updateUgyfelTabla(Ugyfel obj) {
- String url = "http://teszt.tonsofdamage.hu/server/index.php?c=update&t=Ugyfel&d="
- +new Gson().toJson(obj, obj.getClass());
- ConnectionTask conn = new ConnectionTask();
- conn.execute(new String[]{url});
- String jsonOfResponse = conn.response;
- if(Integer.valueOf(jsonOfResponse) == 1) {
- return true;
- }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment