0
は、エミュレータの公式FBアプリをインストールし、ログインして自分のアプリケーションのために働くのApp IDを生成し、まだ私がトレースしたとき:。Android + Facebook sdk + facebook.isSessionValid()が正しく動作していませんか?
facebook.isSessionValid()
私は「偽」を受信...これはバグでしょうか?どんな助けもありがとう!
public class MainActivity extends ListActivity{
Facebook facebook = new Facebook("***********");
String FILENAME = "AndroidSSO_data";
private SharedPreferences mPrefs;
.....
public void add_to_facebook(View view) {
//add to facebook
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);
}
if(!facebook.isSessionValid()) {
facebook.authorize(this, new String[] {}, new DialogListener() {
@Override
public void onComplete(Bundle values) {
Log.d("fb", "onComplete()");
SharedPreferences.Editor editor = mPrefs.edit();
editor.putString("access_token", facebook.getAccessToken());
editor.putLong("access_expires", facebook.getAccessExpires());
editor.commit();
}
@Override
public void onFacebookError(FacebookError error) {
Log.d("fb", "onFacebookError");
}
@Override
public void onError(DialogError e) {
Log.d("fb", "onError()");
}
@Override
public void onCancel() {
Log.d("fb", "onCancel");
}
});
}
//feed dialog
facebook.dialog(this, "feed", new SampleDialogListener());
}
public class SampleDialogListener extends BaseDialogListener {
public void onComplete(Bundle values) {
final String postId = values.getString("post_id");
if (postId != null) {
Log.d("Facebook-Example", "Dialog Success! post_id=" + postId);
} else {
Log.d("Facebook-Example", "No wall post made");
}
}
}
...
}