我已经实现了 2 种共享方法。用脸书和推特。
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_menu);
adapter = new SocialAuthAdapter(new ResponseListener());
}
public void twitter(View view) {
adapter.authorize(this, SocialAuthAdapter.Provider.TWITTER);
}
public void facebook(View view) {
adapter.authorize(this, SocialAuthAdapter.Provider.FACEBOOK);
}
private final class ResponseListener implements DialogListener {
public void onComplete(Bundle values) {
adapter.updateStatus("status");
Log.e("a", "success");
}
public void onError(SocialAuthError error) {
Log.e("a", "error");
}
public void onCancel() {
Log.e("a", "cancel");
}
}
当我第一次单击任何共享按钮时,我会在日志和发布状态中获得“成功”。但是当我第二次点击它时,我有“成功”和“错误”,并且没有发布状态。
例外是
02-12 01:16:40.158: WARN/System.err(12526): org.brickred.socialauth.exception.SocialAuthException: org.brickred.socialauth.exception.SocialAuthException: Status not updated. Return Status code :400
02-12 01:16:40.158: WARN/System.err(12526): at org.brickred.socialauth.provider.FacebookImpl.updateStatus(FacebookImpl.java:276)
02-12 01:16:40.158: WARN/System.err(12526): at org.brickred.socialauth.android.SocialAuthAdapter$4.run(SocialAuthAdapter.java:414)
02-12 01:16:40.158: WARN/System.err(12526): at java.lang.Thread.run(Thread.java:856)
02-12 01:16:40.158: WARN/System.err(12526): Caused by: org.brickred.socialauth.exception.SocialAuthException: Status not updated. Return Status code :400
02-12 01:16:40.158: WARN/System.err(12526): at org.brickred.socialauth.provider.FacebookImpl.updateStatus(FacebookImpl.java:271)
02-12 01:16:40.158: WARN/System.err(12526): ... 2 more