0

我正在尝试使用 Android SDK 发布链接。

单击我的帖子锚不会打开新的浏览器窗口,而是使用当前选项卡(facebook 个人资料/新闻提要)。这会导致用户丢失他/她的 faecbook 浏览器选项卡。

在我看来,这不像预期的行为。其他应用程序(youtube、NewYorkTimes)确实会打开一个新标签。也许它是某种相关的,我的应用程序的站点 url画布 url都设置为提要的链接属性指向的相同 URL。

检查锚的来源,我发现它缺少target='_blank'HTML 属性(youtube 视频帖子确实具有该属性)。

编辑:

也许我没有说清楚......这里的问题不在于将提要发布到用户墙上的阶段。该问题仅在使用提要对话框成功发布后,在用户墙上单击该帖子(帖子的附加图片或链接)时发生。这样做时,您将被重定向到当前浏览器选项卡上的链接地址(Facebook 外)。

编辑2:

我正在使用别人的代码,它是一个 Cordova (Phonegap) facebook 插件。

@Malione,我使用的完整代码可以在https://github.com/mgcrea/cordova-facebook-connect下找到。

我复制粘贴了一个可能是相关功能的功能(位于 下src\com\facebook\android\Facebook.java),并添加了 2 条日志行,它们也可能有帮助:

    /**
 * Cordova interface to display a dialog
 */
public PluginResult dialog(final JSONArray args, final String callbackId) throws JSONException, FileNotFoundException, MalformedURLException, IOException {
    Log.d(CLASS, "dialog() :" + args.toString());
    JSONObject params = args.getJSONObject(0);
    PluginResult pluginResult = new PluginResult(PluginResult.Status.NO_RESULT);

    final String method = params.has("method") ? params.getString("method") : "feed";
    JSONObject optionsObject = (JSONObject)params.get("params");
    final Bundle options = new Bundle();
    Iterator<?> keys = optionsObject.keys();
    while( keys.hasNext() ){
        String key = (String)keys.next();
        options.putString(key, optionsObject.getString(key));
        //if(optionsObject.get(key) instanceof JSONObject)
    }

    final FacebookConnect me = this;
    Runnable runnable = new Runnable() {
        public void run() {
            Log.d("Roei ------->>>>>>>Dialog options:", options.toString());
            Log.d("Roei ------->>>>>>>Dialog context:", me.cordova.getContext().toString() );
            me.getFacebook().dialog(me.cordova.getContext(), method, options, new RegularDialogListener(me, callbackId));
        };
    };
    pluginResult.setKeepCallback(true);
    this.cordova.getActivity().runOnUiThread(runnable);

    return pluginResult;
}

这是日志文件的输出:

08-28 20:21:18.015: D/CordovaLog(25340): picture: https://surf-space.com/wp-content/uploads/spots/user_reports/default/surf-report.jpg
08-28 20:21:18.015: D/CordovaLog(25340): : Line 1172087949 : picture: https://surf-space.com/wp-content/uploads/spots/user_reports/default/surf-report.jpg
08-28 20:21:18.015: I/Web Console(25340): picture: https://surf-space.com/wp-content/uploads/spots/user_reports/default/surf-report.jpg at :1172087949
08-28 20:21:18.025: D/dalvikvm(25340): GC_CONCURRENT freed 395K, 49% free 3328K/6471K, external 598K/1065K, paused 6ms+3ms
08-28 20:21:18.035: D/FacebookConnect(25340): dialog() :[{"method":"feed","params":{"picture":"https:\/\/surf-space.com\/wp-content\/uploads\/spots\/user_reports\/default\/surf-report.jpg",
"method":"feed","description":"Wave height: 1.3 Meters<center \/>Surf conditions: Fine<center \/>","link":"https:\/\/surf-space.com\/spots\/israel\/","name":"Roei Bahumi posted a surf report for: Neurim, Netanya"}}]
08-28 20:21:18.035: D/Roei ------->>>>>>>Dialog options:(25340): Bundle[{picture=https://surf-space.com/wp-content/uploads/spots/user_reports/default/surf-report.jpg, method=feed, description=Wave height: 1.3 
Meters<center />Surf conditions: Fine<center />, name=Roei Bahumi posted a surf report for: Neurim, Netanya, link=https://surf-space.com/spots/israel/}]
08-28 20:21:18.035: D/DroidGap(25340): This will be deprecated December 2012
08-28 20:21:18.035: D/Roei ------->>>>>>>Dialog context:(25340): com.surf_space.surf_space4.MainActivity@405eb938
08-28 20:21:18.035: D/DroidGap(25340): This will be deprecated December 2012
08-28 20:21:19.897: W/InputManagerService(171): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@40a82a20
08-28 20:21:28.125: D/FacebookConnect(25340): RegularDialogListener::onComplete() Bundle[{post_id=839443974_490613954283080}]
08-28 20:21:28.155: D/CordovaLog(25340): FacebookConnect.dialog:{"post_id":"839443974_490613954283080"}
08-28 20:21:28.155: D/CordovaLog(25340): : Line 1172088957 : FacebookConnect.dialog:{"post_id":"839443974_490613954283080"}
08-28 20:21:28.155: I/Web Console(25340): FacebookConnect.dialog:{"post_id":"839443974_490613954283080"} at :1172088957

这是您正在谈论的代码的一部分吗?您是否看到发送到 facebook 的数据中缺少某些内容?

如果没有,您能否将我引导至 Facebook Android SDK 文档页面,该页面解释了如何设置target='_blank',甚至显示了这样做的示例请求,我将不胜感激(并且还将知道在代码中寻找什么)。

4

0 回答 0