Friday, October 22, 2010

Using Facebook SDK in Android Applications

Howto publish images and links with Android in your Facebook Wall using stream.publish method from Facebook SDK:

1st: Download Facebook SDK using git. http://github.com/facebook/facebook-android-sdk
(highly recommended to play a little with Example.java and other methods)

2nd: create a new project from Example.java

3rd: create a Bundle with all the parameters to post and publish it using SampleDialogListener
             Bundle parameters = new Bundle();

               parameters.putString("method","stream.publish");
               String mylink="http://kinesina.blogspot.com";
                String myimagelink="http://kinesina.blogspot.com";
               String attachments = "{
                                   \"name\":\"Location Here\",
                                   \"href\":\""+mylink + "\",
                                   \"caption\":\"Click to view in Google Maps\",
                                   \"media\":[{
                                           \"type\":\"image\",
                                           \"src\": \"http://myimgurl\",
                                           \"href\": \""+myimagelink+"\"}]}";

                parameters.putString("attachment", attachments);
                mFacebook.dialog(Example.this, "stream.publish", parameters, new SampleDialogListener()) ;

4th: Using LocationManager and Google Maps API (which I will explain soon), you can post your location and a link to google maps in your facebook wall! 


If you liked this app (WhereAmI) you can download it from Android Market for free, or mark/like it on facebook (available soon).

Hope you like it, 'cause it is gonna be my first app published in Android Market!

No comments:

Post a Comment