I am trying to get data from a php file in the internet using JSON. It works in a normal class but will not work when using a fragment.
      public static class MagFragment extends Fragment {
    public static final String ARG_MAGAZINE_NUMBER = "magazine_number";
    public MagFragment() {
        // Empty constructor required for fragment subclasses
    }
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.fragment_main, container, false);
        if(i != 0){
            rootView = inflater.inflate(R.layout.fragment_magazine, container, false);
            TextView magText = (TextView) rootView.findViewById(R.id.textViewMag);
            try {
                HttpClient httpclient = new DefaultHttpClient();
                HttpPost httppost = new HttpPost("http://csddata.site11.com");
                HttpResponse response = httpclient.execute(httppost);
                HttpEntity httpEntity = response.getEntity();
                InputStream inputstream = httpEntity.getContent();
                try{
                    BufferedReader reader = new BufferedReader(new InputStreamReader(inputstream,"iso-8859-1"),8);
                    magText.setText(reader.readLine());
                }catch (Exception e){
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } 
        }
        return rootView;
    }
}
It works in a normal class so it must just be because it is a fragment.
I dont have a clue hot to copy and paste the errors ... but the only error that had said which line the error was on was the "HttpResponse response = httpclient.execute(httppost);" Line!
 
     
    