根本问题是 Facebook API 还没有为所有显示类型准备好,并且无法为移动显示显示朋友对话框。您可以做的是更改 Facebook android 库:如果您在打开对话框时使用“弹出”显示模式而不是“触摸”和 www.facebook.com 而不是 m.facebook.com,则会在Facebook 库标准 WebView。
为此,将 Facebook.java 的对话函数更改如下:
protected static String DIALOG_BASE_URL = "https://m.facebook.com/dialog/";
protected static String DIALOG_BASE_URL_FOR_MISSING_SCREENS = "https://www.facebook.com/dialog/";
public void dialog(Context context, String action, Bundle parameters,
final DialogListener listener) {
boolean missingScreen = action.contentEquals("friends") ? true : false;
String endpoint = missingScreen ? DIALOG_BASE_URL_FOR_MISSING_SCREENS : DIALOG_BASE_URL;
endpoint += action;
parameters.putString("display", missingScreen ? "popup" : "touch");
parameters.putString("redirect_uri", REDIRECT_URI);
if (action.equals(LOGIN)) {
parameters.putString("type", "user_agent");
parameters.putString("client_id", mAppId);
} else {
parameters.putString("app_id", mAppId);
}
if (isSessionValid()) {
parameters.putString(TOKEN, getAccessToken());
}
String url = endpoint + "?" + Util.encodeUrl(parameters);
if (context.checkCallingOrSelfPermission(Manifest.permission.INTERNET)
!= PackageManager.PERMISSION_GRANTED) {
Util.showAlert(context, "Error",
"Application requires permission to access the Internet");
} else {
new FbDialog(context, url, listener).show();
}
}
之后,您可能还想从对话框中删除双标题栏。转到 FbDialog.java,并插入类似于 onPageFinished 的内容:
if (url.contains("friends?")) {
mTitle.setHeight(0);
mTitle.setVisibility(View.INVISIBLE);
}