Q:

Android: Trying to create a dialog within a AsyncTask<String object

I'm using a AsyncTask

I use parent to create the intent no errors.
The line to creat a dialog gives a 
parent cannot be resolved to a ye.
 new parent.AlertDialog.Builder(this)
The error I get is that parent does not exist, but I use parent in the same methed to call the intent
code block
     private class SendTextOperation extends AsyncTask {
      @Override
      protected void onPreExecute() {

        //Update UI here

      }

      @Override
      protected String doInBackground(String... params) {
            // Talk to server here to avoid Ui hanging 
          rt=TalkToServer("http://besttechsolutions.biz/projects/bookclub/login.php");
          return(rt);
      }      

      @Override
      protected void onPostExecute(String result) {  

          if (rt.contains("ok")) 
          {

              Intent i = new Intent(parent, cChat.class);
                startActivity(i);
          }
          else
          {

                 new parent.AlertDialog.Builder(this)
                .setTitle("Game Over")
                .setMessage("Your time is up, You saved " 
                        +" Million  more people!!")
                .setNeutralButton("Try Again",new DialogInterface.OnClickListener()
                {
                    public void onClick(DialogInterface dlg, int i)
                    {

                    }} ).show();    

          }
      }

}

A:

For showing AlertDialog from non Activity you will need to pass Current Activity Context to non Activity class in your case to SendTextOperation class.
Create an Constructor for SendTextOperation as :
public class SendTextOperation extends AsyncTask<String,Void,String>{
Context context;
    public SendTextOperation(Context context) {
        this.context = context;
    }

      @Override
      protected void onPreExecute() {

        //Update UI here

      }

      @Override
      protected String doInBackground(String... params) {
            // Talk to server here to avoid Ui hanging 
          rt=TalkToServer("http://besttechsolutions.biz/projects/bookclub/login.php");
          return(rt);
      }      

      @Override
      protected void onPostExecute(String result) {  

          if (rt.contains("ok")) 
          {

              Intent i = new Intent(context, cChat.class);
                startActivity(i);
          }
          else
          {

                 new context.AlertDialog.Builder(context)
                .setTitle("Game Over")
                .setMessage("Your time is up, You saved " 
                        +" Million  more people!!")
                .setNeutralButton("Try Again",new DialogInterface.OnClickListener()
                {
                    public void onClick(DialogInterface dlg, int i)
                    {

                    }} ).show();    

          }
      }

}

and start SendTextOperation AsyncTask as :
SendTextOperation sendtxtasyncTask = new SendTextOperation(CurrentActivity.this);
sendtxtasyncTask.execute("");

