0
public int postToTwitter(String msg) {
    String url = null;

    new ImageSender().execute();
    // Twitlink I have to pass in next line but it showing null
    twitter.updateStatus(msg+" "+twitlink);

    return 1;
}

AsyncTask クラス:

private class ImageSender extends AsyncTask<URL, Integer, Long> {
    private String url;

    protected void onPreExecute() {
        mProgressDialog = ProgressDialog.show(OutgoingHome.this, "", "Sending image...", true);
        mProgressDialog.setCancelable(false);
        mProgressDialog.show();
    }

    protected Long doInBackground(URL... urls) {            
        long result = 0;

        ImageUpload upload = ImageUpload.getTwitpicUploader ("8b8f5db5ca383798509af8459f968dbc",auth);
        try {
            twitlink = upload.upload(new File(path));
            result = 1;
        } catch (Exception e) {        

        }

        return result;
    }

    protected void onPostExecute(Long result) {
        mProgressDialog.cancel();
    }
}
4

1 に答える 1

1

最も簡単な方法は、 のget()メソッドを使用することAsyncTaskです。もう 1 つの方法は、 を実装し、内でそのメソッドOnResultListenerを呼び出すことです。ただし、最初の解決策で十分です。お役に立てれば。onResult()AsyncTask onPostExecute()

于 2012-09-01T08:58:54.650 に答える