我开发了一个推特应用程序。我需要在编辑框中输入文本后,单击按钮,然后将其发布到 Twitter。
任何人都可以发布代码。
我试过了,但我在 setStatus() 方法中遇到了错误。
这是我的代码,请帮忙。
public void onCreate(Bundle savedInstanceState) {
System.setProperty("http.keepAlive", "false");
super.onCreate(savedInstanceState);
setContentView(R.layout.main_oauth);
//check for saved log in details..
checkForSavedLogin();
//set consumer and provider on teh Application service
getConsumerProvider();
//Define login button and listener
buttonLogin = (Button)findViewById(R.id.ButtonLogin);
buttonLogin.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
askOAuth();
}
});
postText = (EditText)findViewById(R.id.editText1);
postbtn = (Button)findViewById(R.id.button1);
postbtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
postTwitter();
}
});
}
protected void postTwitter() {
String message = postText.getText().toString();
System.out.println("Post Twitter.."+message);
Thread t = new Thread() {
public void run() {
twitter = new Twitter();
try
{
//Status to post in Twitter
**twitter.setStatus(postText.getText().toString());**
Toast.makeText(AuthActivity.this, "Article Posted to Twitter Successfully!!", Toast.LENGTH_SHORT).show();
}
catch(Exception e)
{
Toast.makeText(AuthActivity.this, "Network Host not responding",Toast.LENGTH_SHORT).show();
}
}
};
t.start();
}