1

How can i upload a file to the server (a php server) without drive crazy? I've tried all the idea, but i get errors like: android duplicate files during packaging NoClassDefFoundError: org.apache.http.entity.ContentType

Any help? I can't believe that a normali thing like this is quite impossible to do...

I need a simply:

private class upload extends AsyncTask<Void, Integer, Void> {
    @Override
    protected void onPreExecute(){}
    @Override
    protected Void doInBackground(Void... params){
        try {
            // bla bla bla
        }catch(Exception e){}
        return null;
    }
    @Override
    protected void onPostExecute(Void result){
        new register().execute();
    }
}
D Ferra
  • 1,223
  • 3
  • 12
  • 21
  • possible duplicate of [Upload large files on the web server on android](http://stackoverflow.com/questions/3351742/upload-large-files-on-the-web-server-on-android) – Shabbir Dhangot Sep 03 '14 at 11:45

1 Answers1

-1
  private String URL_PERMISSION = "http://yourhost.com/yourphppage.php";

  /**
         * Async task to create a new food category
         * */
        private class AddNewCategory extends AsyncTask<String, Void, Void> {

            boolean isNewCategoryCreated = false;

            @Override
            protected void onPreExecute() {
                super.onPreExecute();
                pDialog1 = new ProgressDialog(MainActivity.this);
                pDialog1.setMessage("Updating Message Status..");
                pDialog1.setCancelable(true);
                pDialog1.show();

            }

            @Override
            protected Void doInBackground(String... arg) {

                //String newCategory = arg[0];

                // Preparing post params

                List<NameValuePair> params = new ArrayList<NameValuePair>();
                params.add(new BasicNameValuePair("message_status", "0"));

                //params.add(new BasicNameValuePair("id", "3"));

                ServiceHandler serviceClient = new ServiceHandler();

                String json1 = serviceClient.makeServiceCall(URL_PERMISSION,
                        ServiceHandler.POST, params);
    //          String json1 = serviceClient.makeServiceCall(URL_Update,
    //                  ServiceHandler.POST, params);

                Log.d("Update Response: ", "> " + json1);

                if (json1 != null) {
                    try {
                        JSONObject jsonObj1 = new JSONObject(json1);
                        boolean error = jsonObj1.getBoolean("error");
                        // checking for error node in json
                        if (!error) {   
                            // new category created successfully
                            isNewCategoryCreated = true;
                        } else {
                            Log.e("Update Message Error: ", "> " + jsonObj1.getString("message"));
                        }

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

                } else {
                    Log.e("JSON Data", "Didn't receive any data from server!");
                }


                return null;
            }

            @Override
            protected void onPostExecute(Void result) {
                super.onPostExecute(result);
                pDialog1.dismiss();
                //new GetContactList().execute();
                //populateSpinner();
                if (isNewCategoryCreated) {
                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            // fetching all categoriesList

                        }
                    });
                }
            }

        }