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;
}
异步任务类:
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();
}
}