How to call a outside method in AlertDialog?
<p>I have a method use to connect HttpGet in AppTools.java:</p>

<pre><code>public class AppTools extends Activity {
public void connectToServerWithURL(String URL)
        throws ClientProtocolException, IOException, JSONException {
/* Start connect */
    new Thread() {
client = new DefaultHttpClient();
request = new HttpGet(URL);
response = client.execute(request);
reader = new BufferedReader(new InputStreamReader(response.getEntity()
            .getContent()));
builder = new StringBuilder();
    for (String s = reader.readLine(); s != null; s = reader.readLine()) {
        builder.append(s);
    }

if (builder != null) {
        /* Transfer to JSONArray */
        jsonTransfer = new JSONObject(builder.toString());
        systemConfigJSONArray = jsonTransfer.getJSONArray(config);
        runOnUiThread(performResult);
    }
       }.start();
} 
private Runnable performResult = new Runnable() {
    public void run() {
        closeProgressDialog();
        performResult(systemConfigJSONArray);
    }
};

/** Connect complete, interface for Override **/
public void performResult(JSONArray resultArray) {
}
</code></pre>

<p>And, in another Activity is extends AppTools:</p>

<pre><code>public class A extends AppTools { 
</code></pre>

<p>in Activity A has a AlertDialog use to select url to connect :</p>

<pre><code>new AlertDialog.Builder(this).setView(aLayout)
.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int        which) {
                    /* Set command */
                    if (spinner_options.getSelectedItemPosition() == 0) {
                        connectToServerWithURL("http://...");
                    } else if (spinner_options
                            .getSelectedItemPosition() == 1) {
                        connectToServerWithURL("http://...");
                    }
                }
            }).setNegativeButton("Cancel", null).show();
</code></pre>

<p>the aLayout in <code>.setView(aLayout)</code> has a Spinner, so the onClick interface of setPositiveButton</p>

<p>will get the selected position of spinner and do the method</p>

<p>but the code can't work, LogCat shows AlertController$ButtonHandler error</p>

<p>What is the problem?</p>
