我試圖寫在Android的代碼,這將有助於從我的應用程序內更新我的Twitter狀態,微博狀態但我有與it.Below問題是代碼片段更新使用JTwitter
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();
}
}
並請可能有人解釋這portio
ok.will那樣做。感謝 – nnanna
發佈你的logcat。 –
請使用twitter4j庫,以下使用twitter集成的答案鏈接,它可以幫助你。 [在Android中集成twitter](http://stackoverflow.com/questions/11357731/integrating-twitter-in-android/11358052#11358052) –