Android Logcat分析问题

Android Logcat分析问题,android,android-intent,android-activity,Android,Android Intent,Android Activity,我的应用程序崩溃和logcat显示了这一点(任何人都可以告诉我我的问题在哪里?当有人需要时,我可以显示我的应用程序代码): 我的代码看起来是这样的(我真的不知道bug在哪里),有人能帮我解决这个问题吗 import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util

我的应用程序崩溃和logcat显示了这一点(任何人都可以告诉我我的问题在哪里?当有人需要时,我可以显示我的应用程序代码):

我的代码看起来是这样的(我真的不知道bug在哪里),有人能帮我解决这个问题吗

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;



import android.accounts.Account;
import android.accounts.AccountManager;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ListView;
import android.widget.Toast;

public class Z_Glowna extends Activity {

private AtomPayListAdapter adapter;
private ProgressDialog pDialog;
private String nazwa, ilosc, id, lat, longi, name;
private double il;
public JSONObject json;
private int sprawdz;
private static final String TAG_MARKET = "nazwa";
private static final String TAG_POSTS = "posts";
private static final String TAG_SZER = "ilosc";
private static final String TAG_USERS = "users";
private static final String TAG_ID = "id";
double Lzakupow[];
double test[];
double ile[];
String zakup[];
int b = 0;
int y = 0;

private JSONArray zakupy = null;

private ArrayList<HashMap<String, String>> mListaMarketow;

    // ids
private static final String TAG_SUCCESS = "success";
private static final String TAG_MESSAGE = "message";

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_list_view);
    setupListViewAdapter();
    setupAddPaymentButton();
    Button but = (Button) findViewById(R.id.but);
    new WczytajZakupy().execute();

    /*
     * but.setOnClickListener(new Button.OnClickListener() {
     * 
     * public void onClick(View arg0) {
     * 
     * new DodajZakupy().execute(); }
     * 
     * });
     */
    /*
     * Lzakupow = Lzakupow(); for (x = 0; x < Lzakupow.length; x++) { String
     * temp = String.valueOf(Lzakupow[x]); // Toast.makeText(this, temp,
     * Toast.LENGTH_SHORT).show(); Log.i("ddd", temp);
     */


}

public String getUsername() {
    AccountManager manager = AccountManager.get(this);
    Account[] accounts = manager.getAccountsByType("com.google");
    List<String> possibleEmails = new LinkedList<String>();

    for (Account account : accounts) {
        // TODO: Check possibleEmail against an email regex or treat
        // account.name as an email address only for certain account.type
        // values.
        possibleEmails.add(account.name);
    }

    if (!possibleEmails.isEmpty() && possibleEmails.get(0) != null) {
        String email = possibleEmails.get(0);
        String[] parts = email.split("@");
        if (parts.length > 0 && parts[0] != null)
            return parts[0];
        else
            return null;
    } else
        return null;
}

public void removeAtomPayOnClickHandler(View v) {
    AtomPayment itemToRemove = (AtomPayment) v.getTag();
    zakup[b] = itemToRemove.getName();
    ile[b] = itemToRemove.getValue();
    adapter.remove(itemToRemove);
    b++;
}

private void setupListViewAdapter() {
    adapter = new AtomPayListAdapter(Z_Glowna.this,
            R.layout.atom_pay_list_item, new ArrayList<AtomPayment>());
    ListView atomPaysListView = (ListView) findViewById(R.id.EnterPays_atomPaysList);
    atomPaysListView.setAdapter(adapter);
}

public void setupAddPaymentButton() {
    findViewById(R.id.EnterPays_addAtomPayment).setOnClickListener(
            new OnClickListener() {

                @Override
                public void onClick(View v) {
                    adapter.insert(new AtomPayment("", 0), 0);
                }
            });
}

public class WczytajZakupy extends AsyncTask<Void, Void, Boolean> {
    /*
     * private ProgressDialog pDialog;
     */
    @Override
    protected void onPreExecute() {
        super.onPreExecute();
        pDialog = new ProgressDialog(Z_Glowna.this);
        pDialog.setMessage("Synchrownizacja z chmurą...");
        pDialog.setIndeterminate(false);
        pDialog.setCancelable(true);
        pDialog.show();
    }

    @Override
    protected Boolean doInBackground(Void... arg0) {
        // we will develop this method in version 2

        mListaMarketow = new ArrayList<HashMap<String, String>>();
        JSONParser jParser = new JSONParser();
        JSONObject json = jParser.getJSONFromUrl(WczytajZakupy);

        try {

            zakupy = json.getJSONArray(TAG_POSTS);

            // looping through all posts according to the json object
            // returned
            for (int i = 0; i < zakupy.length(); i++) {
                JSONObject c = zakupy.getJSONObject(i);

                // gets the content of each tag
                String market = c.getString(TAG_MARKET);
                String users = c.getString(TAG_USERS);
                String dlug = String.valueOf(c.getDouble((TAG_SZER)));
                String id = String.valueOf(c.getDouble((TAG_ID)));

                HashMap<String, String> map = new HashMap<String, String>();

                map.put(TAG_MARKET, market);
                map.put(TAG_SZER, dlug);
                map.put(TAG_USERS, users);
                map.put(TAG_ID, id);

                // adding HashList to ArrayList
                mListaMarketow.add(map);

            }

        } catch (JSONException e) {
            e.printStackTrace();
        }
        return null;
    }

    @Override
    protected void onPostExecute(Boolean result) {
        super.onPostExecute(result);
        try {
            pDialog.dismiss();
            pDialog = null;
        } catch (Exception e) {
            // nothing
        }

        int x = 0;

        // Bundle extras = getIntent().getExtras();
        String user = getUsername();
        String users, idd; // zmienne do obsłużenia wyników z bazy danych

        for (Map<String, String> mListaMar : mListaMarketow) {// pętla
                                                                // sprawdzająca
                                                                // ile dany
                                                                // użytkownik
                                                                // ma
                                                                // dokładnie
                                                                // pozycji
                                                                // zakupowych
                                                                // tworzy
                                                                // licznik
                                                                // który
                                                                // przechowuje
                                                                // zliczoną
                                                                // wartość
            users = mListaMar.get(TAG_USERS);
            if (users.equals(user)) {
                y++;
            }
        }

        Lzakupow = new double[y];

        for (Map<String, String> mListaMar : mListaMarketow) {

            idd = mListaMar.get(TAG_ID);
            users = mListaMar.get(TAG_USERS);
            longi = mListaMar.get(TAG_SZER);
            name = mListaMar.get(TAG_MARKET);
            double ilosc = Double.parseDouble(longi);

            if (users.equals(user)) {
                adapter.insert(new AtomPayment(name, ilosc), 0);
                Lzakupow[x] = Double.parseDouble(idd);
                x++;
            }

        }
        ustawLzakupow(Lzakupow);
        zakup = new String[y];
        ile = new double[y];

    }

}

public class DodajZakupy extends AsyncTask<String, String, String> {

    @Override
    protected void onPreExecute() {
        super.onPreExecute();
        pDialog = new ProgressDialog(Z_Glowna.this);
        pDialog.setMessage("Synchrownizacja z chmurą...");
        pDialog.setIndeterminate(false);
        pDialog.setCancelable(true);
        pDialog.show();
    }

    @Override
    protected String doInBackground(String... args) {
        // TODO Auto-generated method stub
        // Check for success tag
        int success;

        // Retrieving Saved Username Data:
        SharedPreferences sp = PreferenceManager
                .getDefaultSharedPreferences(Z_Glowna.this);
        String post_username = sp.getString("username", "anon");

        int cos = adapter.getCount();

        try {

            for (int x = 0; x < cos; x++) {

                // kowersja wszystkich danych na stringi
                // il = x;
                id = getUsername();
                // id = String.valueOf(il);
                nazwa = adapter.getItem(x).getName();
                il = adapter.getItem(x).getValue();
                ilosc = String.valueOf(il);
                List<NameValuePair> params = new ArrayList<NameValuePair>();
                params.add(new BasicNameValuePair("id", id));
                params.add(new BasicNameValuePair("nazwa", nazwa));
                params.add(new BasicNameValuePair("ilosc", ilosc));

                Log.d("request!", "starting");

                // Posting user data to script
                json = jsonParser.makeHttpRequest(DodajZakupy, "POST",
                        params);
                // full json response
                Log.d("Post Comment attempt", json.toString());
                success = json.getInt(TAG_SUCCESS);
                ustawJ(success);
            }

            // json success element
            success = sprawdz();
            if (success == 1) {
                Log.d("Synchronizacja ukończona!", json.toString());
                // finish();
                return json.getString(TAG_MESSAGE);
            } else {
                Log.d("Błąd synchronizacji!", json.getString(TAG_MESSAGE));
                return json.getString(TAG_MESSAGE);
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }

        return null;
    }

    protected void onPostExecute(String file_url) {
        // dismiss the dialog once product deleted
        pDialog.dismiss();
        if (file_url != null) {
            Toast.makeText(Z_Glowna.this, file_url, Toast.LENGTH_LONG)
                    .show();
        }

    }
}

public class UsunZakupAsync extends AsyncTask<String, String, String> {
    protected void onPreExecute() {
        super.onPreExecute();
        pDialog = new ProgressDialog(Z_Glowna.this);
        pDialog.setMessage("Usuwam wpisy...");
        pDialog.setIndeterminate(false);
        pDialog.setCancelable(true);
        pDialog.show();
    }

    @Override
    protected String doInBackground(String... args) {
        // TODO Auto-generated method stub
        // Check for success tag
        int success;

        // Retrieving Saved Username Data:
        SharedPreferences sp = PreferenceManager
                .getDefaultSharedPreferences(Z_Glowna.this);

        int x = 0;
         Lzakupow = Lzakupow(); 
         List<NameValuePair> params = new ArrayList<NameValuePair>();
         for (x = 0; x < Lzakupow.length; x++) 
         { 
         int idd = (int) Lzakupow[x];
         String id = String.valueOf(idd);
         Log.i("ddd", id);
         params.add(new BasicNameValuePair("id", id));


            JSONObject json = jsonParser.makeHttpRequest(UsunZakupy,
                    "POST", params);


        /*try {
            // Building Parameters
            //List<NameValuePair> params = new ArrayList<NameValuePair>();
            params.add(new BasicNameValuePair("id", id));

            Log.d("request!", "starting");

            // Posting user data to script
            JSONObject json = jsonParser.makeHttpRequest(UsunZakupy,
                    "POST", params);

            // full json response
            Log.d("Post Comment attempt", json.toString());

            // json success element
            success = json.getInt(TAG_SUCCESS);
            if (success == 1) {
                Log.d("Comment Added!", json.toString());
                finish();
                return json.getString(TAG_MESSAGE);
            } else {
                Log.d("Comment Failure!", json.getString(TAG_MESSAGE));
                return json.getString(TAG_MESSAGE);

            }
        } catch (JSONException e) {
            e.printStackTrace();
        }}*/
         }
        return null;

    }

    protected void onPostExecute(String file_url) {
        // dismiss the dialog once product deleted
        pDialog.dismiss();
        if (file_url != null) {
            Toast.makeText(Z_Glowna.this, file_url, Toast.LENGTH_LONG)
                    .show();
        }

    }

}

public void ustawJ(int sprawdz) {
    this.sprawdz = sprawdz;
}

public int sprawdz() {
    return sprawdz;
}

public void ustawLzakupow(double[] Lzakupow) {
    this.Lzakupow = Lzakupow;
}

public double[] Lzakupow() {
    return Lzakupow;
}

@Override
public void onBackPressed() {
    // TODO Auto-generated method stub
    super.onBackPressed();
    // Toast.makeText(this, adapter.getItem(), duration)
    /*int x = 0;
    for (x = 0; x < zakup.length; x++) {
        Toast.makeText(this, zakup[x], Toast.LENGTH_SHORT).show();
        Toast.makeText(this, String.valueOf(ile[x]), Toast.LENGTH_SHORT)
                .show();
        x++;}*/


    new DodajZakupy().execute();
    new UsunZakupAsync().execute();





}
import java.util.ArrayList;
导入java.util.HashMap;
导入java.util.Iterator;
导入java.util.LinkedList;
导入java.util.List;
导入java.util.Map;
导入org.apache.http.NameValuePair;
导入org.apache.http.message.BasicNameValuePair;
导入org.json.JSONArray;
导入org.json.JSONException;
导入org.json.JSONObject;
导入android.accounts.Account;
导入android.accounts.AccountManager;
导入android.app.Activity;
导入android.app.ProgressDialog;
导入android.content.Intent;
导入android.content.SharedReferences;
导入android.os.AsyncTask;
导入android.os.Build;
导入android.os.Bundle;
导入android.preference.PreferenceManager;
导入android.telephony.TelephonyManager;
导入android.util.Log;
导入android.view.view;
导入android.view.view.OnClickListener;
导入android.widget.Button;
导入android.widget.ListView;
导入android.widget.Toast;
公共类Z_Glowna扩展活动{
专用AtomPayListAdapter适配器;
私人对话;
私有字符串nazwa、ilosc、id、lat、longi、name;
私人双il;
公共JSONObject json;
斯普拉兹私人酒店;
私有静态最终字符串TAG_MARKET=“nazwa”;
私有静态最终字符串标记_POSTS=“POSTS”;
私有静态最终字符串标记_SZER=“ilosc”;
私有静态最终字符串标记_USERS=“USERS”;
私有静态最终字符串标记\u ID=“ID”;
双Lzakupow[];
双重测试[];
双ile[];
字符串zakup[];
int b=0;
int y=0;
私有JSONArray zakupy=null;
私人ArrayList mListaMarketow;
//身份证
私有静态最终字符串标记_SUCCESS=“SUCCESS”;
私有静态最终字符串标记_MESSAGE=“MESSAGE”;
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity\u list\u视图);
setupListViewAdapter();
setupAddPaymentButton();
Button but=(Button)findViewById(R.id.but);
新的WczytajZakupy().execute();
/*
*但是.setOnClickListener(新建按钮.OnClickListener(){
* 
*公共void onClick(视图arg0){
* 
*新的DodajZakupy().execute();}
* 
* });
*/
/*
*Lzakupow=Lzakupow();for(x=0;x0&&parts[0]!=null)
退货零件[0];
其他的
返回null;
}否则
返回null;
}
公共无效删除TomPaynClickHandler(视图v){
AtomPayment itemToRemove=(AtomPayment)v.getTag();
zakup[b]=itemToRemove.getName();
ile[b]=itemToRemove.getValue();
适配器。移除(项目移除);
b++;
}
私有void setupListViewAdapter(){
适配器=新的AtomPayListAdapter(Z_Glowna.this,
R.layout.atom_pay_list_项,新建ArrayList());
ListView atomPaysListView=(ListView)findViewById(R.id.EnterPays\u atomPaysList);
setAdapter(适配器);
}
公共无效设置AddPaymentButton(){
findViewById(R.id.EnterPays\u addAtomPayment).setOnClickListener(
新的OnClickListener(){
@凌驾
公共void onClick(视图v){
插入(新的AtomPayment(“,0),0);
}
});
}
公共类WczytajZakupy扩展异步任务{
/*
*私人对话;
*/
@凌驾
受保护的void onPreExecute(){
super.onPreExecute();
pDialog=newprogressdialog(Z_Glowna.this);
pDialog.setMessage(“synchronouswnizacja z chmurą…”);
pDialog.setUndeterminate(假);
pDialog.setCancelable(真);
pDialog.show();
}
@凌驾
受保护的布尔doInBackground(无效…arg0){
//我们将在版本2中开发此方法
mListaMarketow=newarraylist();
JSONParser jParser=新的JSONParser();
JSONObject json=jParser.getJSONFromUrl(WczytajZakupy);
试一试{
zakupy=json.getJSONArray(TAG_POSTS);
//根据json对象在所有帖子中循环
//返回
对于(int i=0;iimport java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;



import android.accounts.Account;
import android.accounts.AccountManager;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ListView;
import android.widget.Toast;

public class Z_Glowna extends Activity {

private AtomPayListAdapter adapter;
private ProgressDialog pDialog;
private String nazwa, ilosc, id, lat, longi, name;
private double il;
public JSONObject json;
private int sprawdz;
private static final String TAG_MARKET = "nazwa";
private static final String TAG_POSTS = "posts";
private static final String TAG_SZER = "ilosc";
private static final String TAG_USERS = "users";
private static final String TAG_ID = "id";
double Lzakupow[];
double test[];
double ile[];
String zakup[];
int b = 0;
int y = 0;

private JSONArray zakupy = null;

private ArrayList<HashMap<String, String>> mListaMarketow;

    // ids
private static final String TAG_SUCCESS = "success";
private static final String TAG_MESSAGE = "message";

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_list_view);
    setupListViewAdapter();
    setupAddPaymentButton();
    Button but = (Button) findViewById(R.id.but);
    new WczytajZakupy().execute();

    /*
     * but.setOnClickListener(new Button.OnClickListener() {
     * 
     * public void onClick(View arg0) {
     * 
     * new DodajZakupy().execute(); }
     * 
     * });
     */
    /*
     * Lzakupow = Lzakupow(); for (x = 0; x < Lzakupow.length; x++) { String
     * temp = String.valueOf(Lzakupow[x]); // Toast.makeText(this, temp,
     * Toast.LENGTH_SHORT).show(); Log.i("ddd", temp);
     */


}

public String getUsername() {
    AccountManager manager = AccountManager.get(this);
    Account[] accounts = manager.getAccountsByType("com.google");
    List<String> possibleEmails = new LinkedList<String>();

    for (Account account : accounts) {
        // TODO: Check possibleEmail against an email regex or treat
        // account.name as an email address only for certain account.type
        // values.
        possibleEmails.add(account.name);
    }

    if (!possibleEmails.isEmpty() && possibleEmails.get(0) != null) {
        String email = possibleEmails.get(0);
        String[] parts = email.split("@");
        if (parts.length > 0 && parts[0] != null)
            return parts[0];
        else
            return null;
    } else
        return null;
}

public void removeAtomPayOnClickHandler(View v) {
    AtomPayment itemToRemove = (AtomPayment) v.getTag();
    zakup[b] = itemToRemove.getName();
    ile[b] = itemToRemove.getValue();
    adapter.remove(itemToRemove);
    b++;
}

private void setupListViewAdapter() {
    adapter = new AtomPayListAdapter(Z_Glowna.this,
            R.layout.atom_pay_list_item, new ArrayList<AtomPayment>());
    ListView atomPaysListView = (ListView) findViewById(R.id.EnterPays_atomPaysList);
    atomPaysListView.setAdapter(adapter);
}

public void setupAddPaymentButton() {
    findViewById(R.id.EnterPays_addAtomPayment).setOnClickListener(
            new OnClickListener() {

                @Override
                public void onClick(View v) {
                    adapter.insert(new AtomPayment("", 0), 0);
                }
            });
}

public class WczytajZakupy extends AsyncTask<Void, Void, Boolean> {
    /*
     * private ProgressDialog pDialog;
     */
    @Override
    protected void onPreExecute() {
        super.onPreExecute();
        pDialog = new ProgressDialog(Z_Glowna.this);
        pDialog.setMessage("Synchrownizacja z chmurą...");
        pDialog.setIndeterminate(false);
        pDialog.setCancelable(true);
        pDialog.show();
    }

    @Override
    protected Boolean doInBackground(Void... arg0) {
        // we will develop this method in version 2

        mListaMarketow = new ArrayList<HashMap<String, String>>();
        JSONParser jParser = new JSONParser();
        JSONObject json = jParser.getJSONFromUrl(WczytajZakupy);

        try {

            zakupy = json.getJSONArray(TAG_POSTS);

            // looping through all posts according to the json object
            // returned
            for (int i = 0; i < zakupy.length(); i++) {
                JSONObject c = zakupy.getJSONObject(i);

                // gets the content of each tag
                String market = c.getString(TAG_MARKET);
                String users = c.getString(TAG_USERS);
                String dlug = String.valueOf(c.getDouble((TAG_SZER)));
                String id = String.valueOf(c.getDouble((TAG_ID)));

                HashMap<String, String> map = new HashMap<String, String>();

                map.put(TAG_MARKET, market);
                map.put(TAG_SZER, dlug);
                map.put(TAG_USERS, users);
                map.put(TAG_ID, id);

                // adding HashList to ArrayList
                mListaMarketow.add(map);

            }

        } catch (JSONException e) {
            e.printStackTrace();
        }
        return null;
    }

    @Override
    protected void onPostExecute(Boolean result) {
        super.onPostExecute(result);
        try {
            pDialog.dismiss();
            pDialog = null;
        } catch (Exception e) {
            // nothing
        }

        int x = 0;

        // Bundle extras = getIntent().getExtras();
        String user = getUsername();
        String users, idd; // zmienne do obsłużenia wyników z bazy danych

        for (Map<String, String> mListaMar : mListaMarketow) {// pętla
                                                                // sprawdzająca
                                                                // ile dany
                                                                // użytkownik
                                                                // ma
                                                                // dokładnie
                                                                // pozycji
                                                                // zakupowych
                                                                // tworzy
                                                                // licznik
                                                                // który
                                                                // przechowuje
                                                                // zliczoną
                                                                // wartość
            users = mListaMar.get(TAG_USERS);
            if (users.equals(user)) {
                y++;
            }
        }

        Lzakupow = new double[y];

        for (Map<String, String> mListaMar : mListaMarketow) {

            idd = mListaMar.get(TAG_ID);
            users = mListaMar.get(TAG_USERS);
            longi = mListaMar.get(TAG_SZER);
            name = mListaMar.get(TAG_MARKET);
            double ilosc = Double.parseDouble(longi);

            if (users.equals(user)) {
                adapter.insert(new AtomPayment(name, ilosc), 0);
                Lzakupow[x] = Double.parseDouble(idd);
                x++;
            }

        }
        ustawLzakupow(Lzakupow);
        zakup = new String[y];
        ile = new double[y];

    }

}

public class DodajZakupy extends AsyncTask<String, String, String> {

    @Override
    protected void onPreExecute() {
        super.onPreExecute();
        pDialog = new ProgressDialog(Z_Glowna.this);
        pDialog.setMessage("Synchrownizacja z chmurą...");
        pDialog.setIndeterminate(false);
        pDialog.setCancelable(true);
        pDialog.show();
    }

    @Override
    protected String doInBackground(String... args) {
        // TODO Auto-generated method stub
        // Check for success tag
        int success;

        // Retrieving Saved Username Data:
        SharedPreferences sp = PreferenceManager
                .getDefaultSharedPreferences(Z_Glowna.this);
        String post_username = sp.getString("username", "anon");

        int cos = adapter.getCount();

        try {

            for (int x = 0; x < cos; x++) {

                // kowersja wszystkich danych na stringi
                // il = x;
                id = getUsername();
                // id = String.valueOf(il);
                nazwa = adapter.getItem(x).getName();
                il = adapter.getItem(x).getValue();
                ilosc = String.valueOf(il);
                List<NameValuePair> params = new ArrayList<NameValuePair>();
                params.add(new BasicNameValuePair("id", id));
                params.add(new BasicNameValuePair("nazwa", nazwa));
                params.add(new BasicNameValuePair("ilosc", ilosc));

                Log.d("request!", "starting");

                // Posting user data to script
                json = jsonParser.makeHttpRequest(DodajZakupy, "POST",
                        params);
                // full json response
                Log.d("Post Comment attempt", json.toString());
                success = json.getInt(TAG_SUCCESS);
                ustawJ(success);
            }

            // json success element
            success = sprawdz();
            if (success == 1) {
                Log.d("Synchronizacja ukończona!", json.toString());
                // finish();
                return json.getString(TAG_MESSAGE);
            } else {
                Log.d("Błąd synchronizacji!", json.getString(TAG_MESSAGE));
                return json.getString(TAG_MESSAGE);
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }

        return null;
    }

    protected void onPostExecute(String file_url) {
        // dismiss the dialog once product deleted
        pDialog.dismiss();
        if (file_url != null) {
            Toast.makeText(Z_Glowna.this, file_url, Toast.LENGTH_LONG)
                    .show();
        }

    }
}

public class UsunZakupAsync extends AsyncTask<String, String, String> {
    protected void onPreExecute() {
        super.onPreExecute();
        pDialog = new ProgressDialog(Z_Glowna.this);
        pDialog.setMessage("Usuwam wpisy...");
        pDialog.setIndeterminate(false);
        pDialog.setCancelable(true);
        pDialog.show();
    }

    @Override
    protected String doInBackground(String... args) {
        // TODO Auto-generated method stub
        // Check for success tag
        int success;

        // Retrieving Saved Username Data:
        SharedPreferences sp = PreferenceManager
                .getDefaultSharedPreferences(Z_Glowna.this);

        int x = 0;
         Lzakupow = Lzakupow(); 
         List<NameValuePair> params = new ArrayList<NameValuePair>();
         for (x = 0; x < Lzakupow.length; x++) 
         { 
         int idd = (int) Lzakupow[x];
         String id = String.valueOf(idd);
         Log.i("ddd", id);
         params.add(new BasicNameValuePair("id", id));


            JSONObject json = jsonParser.makeHttpRequest(UsunZakupy,
                    "POST", params);


        /*try {
            // Building Parameters
            //List<NameValuePair> params = new ArrayList<NameValuePair>();
            params.add(new BasicNameValuePair("id", id));

            Log.d("request!", "starting");

            // Posting user data to script
            JSONObject json = jsonParser.makeHttpRequest(UsunZakupy,
                    "POST", params);

            // full json response
            Log.d("Post Comment attempt", json.toString());

            // json success element
            success = json.getInt(TAG_SUCCESS);
            if (success == 1) {
                Log.d("Comment Added!", json.toString());
                finish();
                return json.getString(TAG_MESSAGE);
            } else {
                Log.d("Comment Failure!", json.getString(TAG_MESSAGE));
                return json.getString(TAG_MESSAGE);

            }
        } catch (JSONException e) {
            e.printStackTrace();
        }}*/
         }
        return null;

    }

    protected void onPostExecute(String file_url) {
        // dismiss the dialog once product deleted
        pDialog.dismiss();
        if (file_url != null) {
            Toast.makeText(Z_Glowna.this, file_url, Toast.LENGTH_LONG)
                    .show();
        }

    }

}

public void ustawJ(int sprawdz) {
    this.sprawdz = sprawdz;
}

public int sprawdz() {
    return sprawdz;
}

public void ustawLzakupow(double[] Lzakupow) {
    this.Lzakupow = Lzakupow;
}

public double[] Lzakupow() {
    return Lzakupow;
}

@Override
public void onBackPressed() {
    // TODO Auto-generated method stub
    super.onBackPressed();
    // Toast.makeText(this, adapter.getItem(), duration)
    /*int x = 0;
    for (x = 0; x < zakup.length; x++) {
        Toast.makeText(this, zakup[x], Toast.LENGTH_SHORT).show();
        Toast.makeText(this, String.valueOf(ile[x]), Toast.LENGTH_SHORT)
                .show();
        x++;}*/


    new DodajZakupy().execute();
    new UsunZakupAsync().execute();





}