我正在开发一个非常简单的 android twitter 应用程序,但是当我尝试在 twitter 上发布推文时,它给了我收到的身份验证为空错误,并且在 android 4.1 中它强制关闭我搜索网络但没有找到任何帮助的应用程序
enter public class StatusClass extends Activity implements OnClickListener{
private Button update;
Twitter twitter;
ConfigurationBuilder cb;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.update_status);
update = (Button)findViewById(R.id.bUpdate);
update.setOnClickListener(this);
cb = new ConfigurationBuilder();
cb.setOAuthConsumerKey("My_Consumer_key");
cb.setOAuthConsumerSecret("My_Consumer_secret_key");
cb.setOAuthAccessToken("My_Oath_access_token");
cb.setOAuthAccessTokenSecret("My_Token_secret");
twitter = new TwitterFactory(cb.build()).getInstance();
}
@Override
public void onClick(View v) {
String tweet="HELLO WORLD!";
try {
Status status = twitter.updateStatus(tweet);
} catch (TwitterException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
W/System.err( 1798): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.processAuthHeader(HttpURLConnectionImpl.java:1153)