Post on facebook wall in android?
Asked Answered
S

3

1

In the Android Gallery in the phone there is an option to share the image to facebook and post it on the wall.I want to post a message or an image on to the wall in the exactly similar way from my app.How can this be done?

My understanding:I believe that it uses facebook app already present in my phone.If that's the case then i can start that particular activity or throw an intent corresponding to that activity from my app.If this is the case can someone let me know what is the corresponding intent that i should be throwing.What are the parameters that i should be passing in the intent and under what keyname should i pass these parameters?

Correct me if my understanding is wrong and let me know how this can be done.

P.S:I have been using the facebook sdk according to this wonderful post Android/Java -- Post simple text to Facebook wall? and it works.But the dialogs don't look that good.That's why i am looking for a different option.

Thanks

Seddon answered 17/4, 2011 at 8:56 Comment(2)
Can you elaborate on 'the dialogs don't look good'? That way any new solution can overcome these limits as you see them.Grinnell
I believe it is shown on a web view and is very congested and the one i had seen in the gallery looks way better.Seddon
E
2

I think you are looking for the ACTION_SEND intent.

See this post.

Edit: and its doc

Second edit: note that if the guy does not have the Facebook app, he won't be able to share. If you use the Facebook API, then he will be able to share to facebook, but facebook only.

Enscroll answered 17/4, 2011 at 11:13 Comment(2)
Yes this was what i was looking for but seems like the ACTION_SEND intent is not handled properly by facebook now. #3515698Seddon
ACTION_SEND is not handled properly but it still works for basic use. What is broken is that it doesn't handle all of the fields in ACTION_SEND and doesn't use the facebook app to handle the action. Instead it opens a webpage to m.facebook.com to handle the wall post (at least it authenticates).Votary
D
1

For a long time research. Finally i found out the solution..

it's works for me very well.

private void postToFacebookViaIntent() {
File mFile = new File(Environment.getExternalStorageDirectory()+ "/images.jpg");
    Intent shareIntent = findFacebookClient();

    if (shareIntent != null &&  mFile!= null) {

        shareIntent.putExtra(Intent.EXTRA_STREAM,Uri.fromFile(mFile)); 
        startActivity(Intent.createChooser(shareIntent, "Share"));
    } else {
        Toast.makeText(SharingActivity.this, "Facebook App is not installed", Toast.LENGTH_SHORT).show();
    }

}

private Intent findFacebookClient() {
    final String twitterApps = "facebook";
    Intent facebookIntent = new Intent();
    facebookIntent.setAction(Intent.ACTION_SEND);
    facebookIntent.setType("image/jpeg");
    final PackageManager packageManager = getPackageManager();
    List<ResolveInfo> list = packageManager.queryIntentActivities(
            facebookIntent, 0);

    for (ResolveInfo resolveInfo : list) {
        String p = resolveInfo.activityInfo.packageName;
        if (p != null && p.contains(twitterApps)) {
            facebookIntent.setPackage(p);
            return facebookIntent;
        }
    }
    return null;
}
Dichromaticism answered 22/1, 2015 at 13:10 Comment(0)
T
0

This article can help you solver this problem. http://vnstep.wordpress.com/2012/04/14/share-via-android/ or Share Text on Facebook from Android App via ACTION_SEND

Touraco answered 20/4, 2012 at 7:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.