Skip to content Skip to sidebar Skip to footer

How To Open A Specific Album Or Photo In Facebook App Using Intent From Your Own Android App

How to open an album or photo in facebook app using intent from your own Android App? I been searching for the specific answer for this one. Most question are about how to open a f

Solution 1:

Actually i made this question to help those who have the same problem like me. As of today (28 March 2016) i just found out how to open an album using intent but i cannot open a photo using intent in the facebook app. I am a beginner in android programming so please bear with me.

I used a button to implement this. Here is the code:

ButtonbuttonOpenALbum= (Button) findViewById(R.id.button);
buttonOpenALbum.setOnClickListener(newView.OnClickListener() {

        @OverridepublicvoidonClick(View v) {
            // TODO Auto-generated method stub//It is a album from a facebook page @ www.facebook.com/thinkingarmyStringalbumID="575146485903630";
            StringuserID="575145312570414";

            Stringurl="facebook:/photos?album="+albumID+"&user="+userID;
            Uriuri= Uri.parse(url);
            Intentintent=newIntent(Intent.ACTION_VIEW, uri);
            startActivity(intent);
        }
    });

If you want to get the albumID and userID of a facebook album try searching on google how or try this one if it helps, https://www.youtube.com/watch?v=sMEmlpmCHLc

Modifying the code to open a specific photo has not produce the expected result. Even though I included the photoID, you still end up in the album. Here is the code:

ButtonbuttonOpenPhoto= (Button) findViewById(R.id.button);
buttonOpenPhoto.setOnClickListener(newView.OnClickListener() {

        @OverridepublicvoidonClick(View v) {
            // TODO Auto-generated method stub//It is a album from a facebook page @ www.facebook.com/thinkingarmyStringalbumID="575146485903630";
            StringuserID="575145312570414";
            StringphotoID="803154029769540";

            Stringurl="facebook:/photos?album="+albumID+"&photo="+photoID+"&user="+userID;
            Uriuri= Uri.parse(url);
            Intentintent=newIntent(Intent.ACTION_VIEW, uri);
            startActivity(intent);
        }
    });

I can't be sure why. I tried looking but some say the urls of facebook is undocumented. If I may, I think you cannot open a specific photo because upon observation, facebook open a photo in full screen, meaning it is a different Activity than the Main Activity which handles the incoming Intent. The Main Activity of the facebook app only handles the intent up to opening a specific album.

I hope I can help other "new android coders" with my first post.

NB: I just learn coding using google and stackoverflow. It's my way of giving back. Thanks.

Solution 2:

Launch a view intent with the following URL

https://www.facebook.com/photo.php?fbid={photo_id}

IntentbrowserIntent=newIntent(Intent.ACTION_VIEW, Uri.parse(url));
            ctx.startActivity(browserIntent);

If the app is installed, it will prompt the user to open in app, otherwise it will use the browser

Solution 3:

Some useful information at Open Facebook Page in Facebook App (if installed) on Android

In particular, new versions of facebook app work with

Uri.parse("fb://facewebmodal/f?href=" + FACEBOOKURL

I found this the simplest approach to acheive what was needed.

Note also that to get the URL you can go to the facebook album (on facebook desktop), click the three dots next to "Edit" and "Tag" and select "Get Link". I found this more reliable than simply copying the URL from the browser.

Post a Comment for "How To Open A Specific Album Or Photo In Facebook App Using Intent From Your Own Android App"