How do I share images on Facebook using Facebook Android SDK?
-
I read Facebook Android SDK's known issue: Binary API parameters (such as uploading pictures) is not yet supported. Any suggestions? Thanks!!!
-
Answer:
public void postImageToWall() { facebook.authorize( this, new String[] { "user_photos,publish_checkins,publish_actions,publish_stream" }, new DialogListener() { @Override public void onFacebookError(FacebookError e) { // TODO Auto-generated method stub } @Override public void onError(DialogError dialogError) { // TODO Auto-generated method stub } @Override public void onComplete(Bundle values) { postImageonWall(); } @Override public void onCancel() { // TODO Auto-generated method stub } }); } private void postImageonWall() { byte[] data = null; Bitmap bi = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher); ByteArrayOutputStream baos = new ByteArrayOutputStream(); bi.compress(Bitmap.CompressFormat.JPEG, 100, baos); data = baos.toByteArray(); Bundle params = new Bundle(); params.putString(Facebook.TOKEN, facebook.getAccessToken()); params.putString("method", "photos.upload"); params.putByteArray("picture", data); params.putString("caption", "Dessert Dash in Android "); AsyncFacebookRunner mAsyncRunner = new AsyncFacebookRunner(facebook); mAsyncRunner.request(null, params, "POST", new SampleUploadListener(), null); } class SampleUploadListener implements AsyncFacebookRunner.RequestListener { @Override public void onComplete(String response, Object state) { } @Override public void onIOException(IOException e, Object state) { } @Override public void onFileNotFoundException(FileNotFoundException e, Object state) { } @Override public void onMalformedURLException(MalformedURLException e, Object state) { } @Override public void onFacebookError(FacebookError e, Object state) { } }
Ayan Bhattacharyya at Quora Visit the source
Related Q & A:
- How do I share my groups on my yahoo 360 page?Best solution by Yahoo! Answers
- How do I share a photo set from Flickr on my Yahoo 360 page?Best solution by Yahoo! Answers
- How to I get images to show when I get an email?Best solution by Yahoo! Answers
- How do I share large files?Best solution by Yahoo! Answers
- How do I share my vonage internet connection with my other computer?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.