1

我有一个新应用程序,我正在尝试将其实现为“号召性用语” facebook 页面按钮,但我不知道应该在“应用程序链接”文本框中写什么。

他们放了一个示例链接:example://location/123456

但我不知道它指的是什么或我的应用程序的应用程序链接是什么。

试图在互联网上找到任何有关它的信息,但找不到任何有用的解决方案,因为我的应用程序中没有应用程序链接(没有产品等)

我的目标是,当用户点击 Facebook 的“使用应用程序”时,如果未安装,它会将他重定向到该应用程序或谷歌 Play 商店应用程序页面。

我不是在谈论在我的应用程序中打开应用程序,而是在谈论在我的 Facebook 页面中打开我的应用程序

在此处输入图像描述

在此处输入图像描述

4

2 回答 2

1

您可以使用 wiki 中的下一个代码:

/** Open another app.
 * @param context current Context, like Activity, App, or Service
 * @param packageName the full package name of the app to open
 * @return true if likely successful, false if unsuccessful
 */
public static boolean openApp(Context context, String packageName) {
    PackageManager manager = context.getPackageManager();
    try {
        Intent i = manager.getLaunchIntentForPackage(packageName);
        if (i == null) {
            return false;
            //throw new PackageManager.NameNotFoundException();
        }
        i.addCategory(Intent.CATEGORY_LAUNCHER);
        context.startActivity(i);
        return true;
    } catch (PackageManager.NameNotFoundException e) {
        return false;
    }
}

示例用法:

openApp(this, "com.google.android.maps.mytracks");

你可以从这里阅读

要在 FB 中发布消息,请参阅下一篇文章,也许会很有用How to open the Facebook Write Post with some predefined text and image

于 2015-09-11T08:20:49.600 回答
0

您应该使用 Try/Catch。如果用户有 Facebook 应用程序,fb://page/12345 链接将在应用程序中打开。否则,Catch 代码将运行。

        @Override
        public void onClick(View v) {
            try {
                startActivity(new Intent(Intent.ACTION_VIEW, Uri
                        .parse("fb://page/12345"))); //12345 is Facebook page number
            } catch (Exception e) {
                //open play link in browser
                startActivity(new Intent(Intent.ACTION_VIEW, Uri
                        .parse("http://play.google.com/etc")));
            }
        }
于 2015-09-11T08:21:52.853 回答