我正在尝试在 android 中编写一个代码,这将有助于从我的应用程序中更新我的 twitter 状态,但我遇到了问题。下面是代码片段
public void onClick(View v) {
String statusText = edit.getText().toString();
new PostToTwitter().execute(statusText);
}
public static String getLogtag() {
return LOGTAG;
}
class PostToTwitter extends AsyncTask<String, Void, String> {
@Override
protected String doInBackground(String... params) {
try{
Twitter twitter = new Twitter("screenname", "password");
// twitter.getStatus("winterstein");
twitter.setAPIRootUrl("https://twitter.com/#!/nindevworks");
twitter.setStatus(params[0]);
Log.d(TweetActivity.getLogtag(),"Successfully Posted: " + params[0]);
return "Successfully Posted: " + params[0];
} catch (TwitterException e) {
Log.e(TweetActivity.getLogtag(),"Died ", e);
e.printStackTrace();
return "Failed Posting: " + params[0];
}
}
@Override
protected void onPostExecute(String result) {
// TODO Auto-generated method stub
super.onPostExecute(result);
Toast.makeText(TweetActivity.this, "result " + result ,Toast.LENGTH_SHORT).show();
}
}
请有人解释一下这部分