简体   繁体   中英

Android open facebook page link in facebook app if installed ,

how to open Facebook page link in Facebook App if installed , and if the app is not installed open in default browser in android ??

i tried this code but its not working ??

     Face.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent intent = null;
            String Facebook = dbList.get(0).getFacebook().toString();
            try {
                // get the Twitter app if possible
                getPackageManager().getPackageInfo("com.facebook.android", 0);
                intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/" +Facebook));
                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            } catch (Exception e) {
                // no Twitter app, revert to browser
                intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/?hl=en"));
            }
            startActivity(intent);
        }
    });

check this link here

here more answer and this help you

click here Open Facebook page from Android app?

Using this code you can open user profile

public static void opneFacebookProfile(Activity activity, String id) {
        Intent facebookIntent = new Intent(Intent.ACTION_VIEW);
        String facebookUrl = getFacebookPageURL(activity, id);
        facebookIntent.setData(Uri.parse(facebookUrl));
        activity.startActivity(facebookIntent);
    }

I work with Unity Android games. The task is to open a Facebook Fan page in the FB app if it is installed. All I need to do is:

  1. Create Android Library and check if FB installed:

     public boolean isFbInstalled(Activity a) { PackageManager packageManager = a.getApplicationContext().getPackageManager(); try { int versionCode = packageManager.getPackageInfo("com.facebook.katana", 0).versionCode; if (versionCode >= 3002850) { //newer versions of fb app, no need to handle older return true; } } catch (PackageManager.NameNotFoundException e) { return false; } return false;

    }

  2. Go to this service and use generated links for different platforms :)

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