Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Try these Facebook open-source examples:</p> <p><a href="https://github.com/facebook/facebook-android-sdk" rel="nofollow">https://github.com/facebook/facebook-android-sdk</a></p> <p>in this examples under <strong>hackbook</strong> for uploading photos to Facebook from sdcard!</p> <p>(or)</p> <p>Try this code for upload image to facebook from sdcard</p> <pre><code>byte[] data = null; try { FileInputStream fis = new FileInputStream(PATH_TO_FILE); Bitmap bi = BitmapFactory.decodeStream(fis); ByteArrayOutputStream baos = new ByteArrayOutputStream(); bi.compress(Bitmap.CompressFormat.JPEG, 100, baos); data = baos.toByteArray(); } catch (FileNotFoundException e) { e.printStackTrace(); Log.d("onCreate", "debug error e = " + e.toString()); } Bundle params = new Bundle(); params.putString("method", "photos.upload"); params.putByteArray("picture", data); Facebook facebook = new Facebook(FACEBOOK_APP_ID); AsyncFacebookRunner mAsyncRunner = new AsyncFacebookRunner(facebook); mAsyncRunner.request(null, params, "POST", new RequestListener() { public void onMalformedURLException(MalformedURLException e, Object state) { Log.d("request RequestListener", "debug onMalformedURLException"); } public void onIOException(IOException e, Object state) { Log.d("request RequestListener", "debug onIOException"); } public void onFileNotFoundException(FileNotFoundException e, Object state) { Log.d("request RequestListener", "debug onFileNotFoundException"); } public void onFacebookError(FacebookError e, Object state) { Log.d("request RequestListener", "debug onFacebookError"); } public void onComplete(String response, Object state) { Log.d("request RequestListener", "debug onComplete"); } }, null); </code></pre> <p>Note: You must set Permission for internet and Sdcard Reading manifest xml file on your project</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload