简体   繁体   中英

Facebook Android App Link

I have a new app and I'm trying to implement it to "Call to Action" facebook page button, but I have no idea what I shall write in the "App link" text box.

They put an example link of: example://location/123456

But I have no idea what it's refering to or what's the App Link of my app.

Tried to find anything about it on the Internet but couldn't find any helpful solution since I have no app links in my app (no products etc)

My goal is that when the user clicks on Facebook "Use App" , it will redirect him to the app or the google play store app page if it's not installed..

I'm not talking about open app in my app, im talking about open my app in my facebook page

在此处输入图片说明

在此处输入图片说明

You can use the next code from the 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;
    }
}

Example usage:

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

You can read it from here

To post a message in FB, see the next post, maybe it will be useful How to open the Facebook Write Post with some pre defined text and image

You should use Try/Catch. if user have Facebook app, fb://page/12345 link will open in app. Else, Catch code will run.

        @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")));
            }
        }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM