title: How can i call Toast.makeText() according to result of AsyncTask in protected String doInBackground method?
body: <p>I fetched data from the database in AsyncTask and if it is null, I want to Toast a warning text. I tried in AsyncTask but i learned that it isn't called in a worker thread. Here is my doInBackground method:</p>
  
  <pre><code>protected String doInBackground(Boolean... params) {
          String result = null;
          StringBuilder sb = new StringBuilder();
          try {   
              HttpClient httpclient = new DefaultHttpClient();
              HttpGet httppost = new HttpGet( "http://191.162.2.235/getProducts.php?login=1&amp;user_name="+UserName+"&amp;user_pass="+Password);
              HttpResponse response = httpclient.execute(httppost);
              if (response.getStatusLine().getStatusCode() != 200) {
                  Log.d("MyApp", "Server encountered an error");
              }
              BufferedReader reader = new BufferedReader(
                      new InputStreamReader(
                              response.getEntity().getContent(), "UTF8"));  
              sb = new StringBuilder();
              sb.append(reader.readLine() + "\n");
              String line = null;
              while ((line = reader.readLine()) != null) {
                  sb.append(line + "\n");
              }
              result = sb.toString();
           if (  result == null  )        {
          //   Toast.makeText(getApplicationContext(), "You entered wrong values.", Toast.LENGTH_LONG).show(); 
               asyncTask.cancel(true);
              Intent  inte=new Intent(MainActivity.this, MainActivity.class);
              inte.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 
              inte.addCategory(Intent.CATEGORY_HOME);
                  startActivity(inte);                                
              }
          } 
          catch (Exception e) {
              Log.e("log_tag", "Error converting result " + e.toString());
                               }
          return result;
      }
  </code></pre>
  
  <p>I canceled the task and create a new intent in my code. You don't care them. You see Toast.makeText.. line, I tried like this one of course it gives error. How can i do this? If it isn't called in AsyncTask, how should i call? </p>