我有一个需要邀请 facebook 朋友的 android 应用程序。我使用下面的代码
WebDialog requestsDialog = (
new WebDialog.RequestsDialogBuilder(FacebookLogin.this,
Session.getActiveSession(),
params))
.setOnCompleteListener(new OnCompleteListener() {
@Override
public void onComplete(Bundle values,
FacebookException error) {
if (error != null) {
if (error instanceof FacebookOperationCanceledException) {
Toast.makeText(FacebookLogin.this.getApplicationContext(),
"Request cancelled",
Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(FacebookLogin.this.getApplicationContext(),
"Network Error",
Toast.LENGTH_SHORT).show();
}
} else {
final String requestId = values.getString("request");
if (requestId != null) {
Toast.makeText(FacebookLogin.this.getApplicationContext(),
"Request sent",
Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(FacebookLogin.this.getApplicationContext(),
"Request cancelled",
Toast.LENGTH_SHORT).show();
}
}
}
})
.build();
requestsDialog.show();
但它会在“if (error instanceof FacebookOperationCanceledException)”行抛出语法错误“不兼容的条件操作数类型 FacebookException 和 FacebookOperationCanceledException”。我错过了什么吗?