title: Error when trying to use toast in android application
body: <p>in my application i am fetching json data from online server. and after that i am trying to display the data by toast. but the application stop working. if i commented the toast section then the application runs smoothly. so i think there is a problem in toast section. so guys plz help me to find out the reason for the problem</p>
  
  <pre><code>   package com.example.getdata;
  
  import java.io.BufferedReader;
  import java.io.IOException;
  import java.io.InputStreamReader;
  import java.util.ArrayList;
  import java.util.List;
  
  import org.apache.http.HttpResponse;
  import org.apache.http.NameValuePair;
  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.json.JSONArray;
  import org.json.JSONException;
  import org.json.JSONObject;
  
  
  
  
  
  import android.os.Bundle;
  import android.util.Log;
  import android.view.View;
  import android.widget.EditText;
  import android.widget.TextView;
  import android.widget.Toast;
  import android.app.Activity;
  
  public class MainActivity extends Activity {
  
      EditText password,username;
      String pass,user;
      //TextView output;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
      }
  
  
      public void onConnect(View v) {
  
  
  
  
           new Thread(){
               public void run(){
                   HttpClient myClient = new DefaultHttpClient();
                   HttpPost post = new HttpPost("http://tusharinfotech.com/debasish/get_data.php");
               try {
                       List&lt;NameValuePair&gt; myArgs = new ArrayList&lt;NameValuePair&gt;();
                      // myArgs.add(new BasicNameValuePair("username", user));
                      // myArgs.add(new BasicNameValuePair("password", pass));
                       post.setEntity(new UrlEncodedFormEntity(myArgs));
                       HttpResponse myResponse = myClient.execute(post);
                       BufferedReader br = new BufferedReader( new InputStreamReader(myResponse.getEntity().getContent()));
                       String line = "";
                       String data1 ="";
                       while ((line = br.readLine()) != null)
                       {
                           try {
                              JSONArray myarray = new JSONArray(line);
                              for(int i=0;i&lt;myarray.length();i++){
                                  JSONObject jsonObject = myarray.getJSONObject(i); 
                                  int id = Integer.parseInt(jsonObject.optString("FOOD_ID").toString());
                                  String name = jsonObject.optString("FOOD_NAME").toString();
                                  data1 += "Node"+i+" : \n id= "+ id +" \n Name= "+ name +" \n ";  
                              }
  
                          //Log.d("mytag",data);
                              //this application stop working for this toast part.. if i commented it then the application run smoothly
                              Toast.makeText(getApplicationContext(),data1, Toast.LENGTH_LONG).show();
                          } catch (JSONException e) {
                              // TODO Auto-generated catch block
                              e.printStackTrace();
                          }
                           //EditText output1 = (EditText) findViewById(R.id.editText1);
                          // output1.setText(data);
                           Log.d("mytag", line);
  
                       }
                  }
                  catch (IOException e) {
                      e.printStackTrace();
                  }
               }
           }.start();
  
       }
  
  
  
  }
  </code></pre>