Не удалось опубликовать ответ от AsyncTask на MainActivity [закрыто]

Я новичок в разработке приложений для Android. Пожалуйста, найдите мой код для AsyncTask для подключения URL, когда пользователь нажимает кнопку.

    package in.mosto.geeglobiab2bmobile;

    import java.io.IOException;
    import java.net.HttpURLConnection;
    import java.util.ArrayList;
    import java.util.List;

    import org.apache.http.HttpResponse;
    import org.apache.http.NameValuePair;
    import org.apache.http.StatusLine;
    import org.apache.http.client.ClientProtocolException;
    import org.apache.http.client.HttpClient;
    import org.apache.http.client.entity.UrlEncodedFormEntity;
    import org.apache.http.client.methods.HttpPost;
    import org.apache.http.impl.client.DefaultHttpClient;
    import org.apache.http.message.BasicNameValuePair;
    import org.apache.http.util.EntityUtils;

    import android.os.AsyncTask;

    public class OnbuttonclickHttpPost extends AsyncTask {
        @Override
        protected String doInBackground(String... params) {
            byte[] result = null;
            String str = "";
           // Create a new HttpClient and Post Header
            HttpClient httpclient = new DefaultHttpClient();
            HttpPost httppost = new HttpPost("http://URL_HERE/login.php");

            try {
                    // Add your data
                    List nameValuePairs = new ArrayList(2);
                    nameValuePairs.add(new BasicNameValuePair("mobile", params[0]));
                    nameValuePairs.add(new BasicNameValuePair("password", params[1]));
                    httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

                    // Execute HTTP Post Request
                    HttpResponse response = httpclient.execute(httppost);
                    StatusLine statusLine = response.getStatusLine();
                    if(statusLine.getStatusCode() == HttpURLConnection.HTTP_OK){
                    result = EntityUtils.toByteArray(response.getEntity());
                    str = new String(result, "UTF-8");
                }
              } catch (ClientProtocolException e) {
                // TODO Auto-generated catch block
            } catch (IOException e) {
                // TODO Auto-generated catch block
            }  
            return str;
        }

        /**
         * on getting result
         */
        @Override
        protected void onPostExecute(String result) {
            // something with data retrieved from server in doInBackground
            //Log.v("Response ", result);

            MainActivity main = new MainActivity();

            if(result.equals("NO_USER_ERROR")){
                main.showNewDialog("There is no user existed with the given details.");
            }else if(result.equals("FIELDS_ERR")){
                main.showNewDialog("Please enter username and password.");
            }else{
                main.startRecharge(result);
            }
        }
    }

Смотрите мои основные методы деятельности:

    OnbuttonclickHttpPost t = new OnbuttonclickHttpPost();
    t.execute(mobile.getText().toString(),pass.getText().toString());

public void startRecharge(String param){
    Intent inte = new Intent(MainActivity.this.getBaseContext(), StartRecharge.class);
    startActivity(inte);
}

public void showNewDialog(String alert){
    new AlertDialog.Builder(this)
        .setTitle("Please correct following error")
        .setMessage(alert)
        .setPositiveButton("Okay", new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                // TODO Auto-generated method stub
                dialog.dismiss();
            }
        })
        .show();
}

Здесь я'Я получаю ошибку. Я нене знаю, что не так с моим кодом. Кто-нибудь может мне помочь, пожалуйста ?

Ответы на вопрос(3)

Ваш ответ на вопрос