我遵循 API facebook 指南,代码如下:
ib2 = (ImageButton) findViewById(R.id.imageButton2);
list = new OnClickListener() {
public void onClick(View v) {
/*
* Get existing access_token if any
*/
mPrefs = getPreferences(MODE_PRIVATE);
String access_token = mPrefs.getString("access_token", null);
long expires = mPrefs.getLong("access_expires", 0);
if(access_token != null) {
facebook.setAccessToken(access_token);
}
if(expires != 0) {
facebook.setAccessExpires(expires);
}
/*
* Only call authorize if the access_token has expired.
*/
if(!facebook.isSessionValid()) {
facebook.authorize(Answer.this, new String[] {"user_about_me","publish_checkins"}, new DialogListener() {
public void onComplete(Bundle values) {
SharedPreferences.Editor editor = mPrefs.edit();
editor.putString("access_token", facebook.getAccessToken());
editor.putLong("access_expires", facebook.getAccessExpires());
editor.commit();
}
public void onFacebookError(FacebookError error) {}
public void onError(DialogError e) {}
public void onCancel() {}
});
}
}};
ib2.setOnClickListener(list);
和
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
facebook.authorizeCallback(requestCode, resultCode, data);
}
每一个都在正确的位置与正确的声明。和...
第一次在按钮上执行 Onclick 时,facebook 要求我接受我的应用程序所需的权限。
但...
我第二次在同一个按钮上单击时,facebook 窗口没有打开。为什么会这样?
如果我设置了权限,我应该看到授权OK!!!