title: putting jsonAsync code into seperate class... Android
body: <p>I tried to make my code to be like this:
  <a href="https://github.com/jbeerdev/BrightHubCode/blob/master/src/com/bright/hub/background/WebServiceBackgroundActivity.java" rel="nofollow">https://github.com/jbeerdev/BrightHubCode/blob/master/src/com/bright/hub/background/WebServiceBackgroundActivity.java</a>
  This is how I call and send with the Async class, that seems to be fine.
  If I put all the code in my MainActivity it just works, but I can't seem to get this code via a external class to work.</p>
  
  <p>My MainActivity code: (parts which matter)</p>
  
  <pre><code>public class MainActivity extends FragmentActivity implements ActionBar.OnNavigationListener {
  
  private static final String url = "http://www.somesite.com/JSON.php";
  public String post;
  public ListView listView;
  public String jsonResult;
  
  protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  initializeDialog();
  setContentView(R.layout.activity_main);
  listView = (ListView) findViewById(R.id.listView1);
  accessWebService();
  }
  private void accessWebService() {
      JsonReadTask jsonTask = new JsonReadTask();
      jsonTask.execute(new String[] { url, post },this);
  }
  
  private void initializeDialog() {
      dialog = ProgressDialog.show(MainActivity.this, "", "LoadingData. Wait...", true);
      dialog.show();
      }   
  
      public void ListDrawer() {
      List&lt;Map&lt;String, String&gt;&gt; galleryList = new ArrayList&lt;Map&lt;String, String&gt;&gt;();
  
      try {
  
     JSONObject jsonResponse = new JSONObject(jsonResult);
     JSONArray jsonMainNode = jsonResponse.optJSONArray("galleries");
  
     for (int i = 0; i &lt; jsonMainNode.length(); i++) {
      JSONObject jsonChildNode = jsonMainNode.getJSONObject(i);
  
      String loc = jsonChildNode.optString("loc");
      String foto = jsonChildNode.optString("foto");
      String outPut = "http://www.somesite.com/images/" + loc + foto;
      galleryList.add(createGallery("galleries", outPut));
     }
    } catch (JSONException e) {
    //Toast.makeText(getApplicationContext(), "Error" + e.toString(),
       //Toast.LENGTH_LONG).show();
    }
  
  }
  </code></pre>
  
  <p>But on the Async class:
  <a href="https://github.com/jbeerdev/BrightHubCode/blob/master/src/com/bright/hub/background/WebServiceAsyncTask.java" rel="nofollow">https://github.com/jbeerdev/BrightHubCode/blob/master/src/com/bright/hub/background/WebServiceAsyncTask.java</a>
  ^I get these kinds of errors: "java.lang.String[] cannot be cast to java.lang.String"
  So where this happens: "String serviceUrl = (String) params[0];" is where I have problems..?
  It's in the "doInBackground" at least: "An error occured while executing doInBackground()"</p>
  
  <p>My Async class code: (parts which matter)</p>
  
  <pre><code>    public class JsonReadTask extends AsyncTask&lt;Object, Void, String&gt; {
      MainActivity callerActivity;
      @Override
      public String doInBackground(Object... params) {
  
      callerActivity = (MainActivity) params[1];
      HttpClient httpclient = new DefaultHttpClient();
      String theurl = (String) params[0]; //urlJSON
  
      HttpPost httppost = new HttpPost(theurl);
      try {
      List&lt;NameValuePair&gt; nameValuePairs = new ArrayList&lt;NameValuePair&gt;(2);
      String thepost = (String) params[1]; //tablename
      nameValuePairs.add(new BasicNameValuePair("getgallery", "thepost"));
      httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
      HttpResponse response = httpclient.execute(httppost);
  
  
          callerActivity.jsonResult = inputStreamToString(response.getEntity().getContent()).toString();
      }
  
      catch (ClientProtocolException e) {
      e.printStackTrace();
      } catch (IOException e) {
      e.printStackTrace();
      }
      return null;
      }
  </code></pre>
  
  <p>The apps crashes on boot giving a Dialog it crashed.
  Thanks in advance for the help!</p>
  
  <p>Edit
  My logcat: <a href="http://pastebin.com/XZaNZTTg" rel="nofollow">http://pastebin.com/XZaNZTTg</a></p>