Google上的所有搜索和stackoverflow如何在Facebook上发布我可以找到的相同的弃用代码。这是带有捆绑包的简单墙贴的旧代码。
Bundle params = new Bundle(); params.putString( “姓名”, “我”);
fb.dialog(MainActivity.this,“feed”,params,new DialogListener(){ ,.. }
请注意,更新代码的确切替代品。
答案 0 :(得分:0)
这会替代该代码,
Bundle params = new Bundle();
params.putString("name","Me");
WebDialog feedDialog = (
new WebDialog.FeedDialogBuilder(getActivity(),
Session.getActiveSession(),
params))
.setOnCompleteListener(new OnCompleteListener() {
@Override
public void onComplete(Bundle values,
FacebookException error) {
if (error == null) {
// When the story is posted, echo the success
// and the post Id.
final String postId = values.getString("post_id");
if (postId != null) {
Toast.makeText(getActivity(),
"Posted story, id: "+postId,
Toast.LENGTH_SHORT).show();
} else {
// User clicked the Cancel button
Toast.makeText(getActivity().getApplicationContext(),
"Publish cancelled",
Toast.LENGTH_SHORT).show();
}
} else if (error instanceof FacebookOperationCanceledException) {
// User clicked the "x" button
Toast.makeText(getActivity().getApplicationContext(),
"Publish cancelled",
Toast.LENGTH_SHORT).show();
} else {
// Generic, ex: network error
Toast.makeText(getActivity().getApplicationContext(),
"Error posting story",
Toast.LENGTH_SHORT).show();
}
}
})
.build();
feedDialog.show();