我正在构建一个twitter客户端,当它打开它时,它会强制关闭,logat在OnCreate()方法中显示了异常,
这里出了什么问题?
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// find views by id
buttonUpdate = (Button) findViewById(R.id.buttonUpdate);
textStatus = (EditText) findViewById(R.id.textStatus);
// Add listener
buttonUpdate.setOnClickListener(this);
//Initialize twitter
prefs = PreferenceManager.getDefaultSharedPreferences(this);
String username = prefs.getString("username", "n/a");
String password = prefs.getString("password", "n/a");
if (username != null && password != null){
twitter = new Twitter(username, password);
}
}我想是在这条线上。
twitter = new Twitter(username, password);它带有下划线,并显示“构造函数Twitter(String,String)已弃用”
这是什么意思?
发布于 2014-03-03 22:06:24
Twitter不再支持名称/密码基本身份验证。这个构造器只适用于非Twitter站点,比如identi.ca。
您需要使用以下方法...
public Twitter(java.lang.String name,
Twitter.IHttpClient client)您可以找到有关此方法here的更多文档
https://stackoverflow.com/questions/22148645
复制相似问题