Note that there are some explanatory texts on larger screens.

plurals
  1. POFacebook SDK 3 for Android gives error when requesting a photo upload
    text
    copied!<p>I have a Bitmap image in my Android application and I need to upload it to the logged user's wall, including a caption message.</p> <p>I've already implemented the Login button that (should) set-up the Session and, after a check with <code>session.isOpened()</code>, I call the method <code>newUploadPhotoRequest(session, image, callback)</code>.</p> <p>The problem is that the picture is never uploaded. Apparently, the login works because session.isOpened() return true after the user clicked on the Login Button. This means that API key, debug/release key hashes and all those stuffs are correct.</p> <p>Instead, the callback of the upload method return this response:</p> <pre><code>{Response: responseCode: 200, graphObject: null, error: {HttpStatus: -1, errorCode: -1, errorType: null, errorMessage: null}, isFromCache:false} </code></pre> <p>Following: the code snippet behind the Activity (called <code>FacebookActivity</code>) that should upload the Bitmap.</p> <pre><code>private void startSending() { ((LinearLayout)findViewById(R.id.LoginLayout)).setVisibility(View.INVISIBLE); ((LinearLayout)findViewById(R.id.SendingLayout)).setVisibility(View.VISIBLE); Request photoRequest = Request.newUploadPhotoRequest(Session.getActiveSession(), picture, new Request.Callback() { @Override public void onCompleted(Response response) { Toast toast; if(response.getError() == null) { toast = Toast.makeText(getApplicationContext(), getString(R.string.ask_facebook_sent), Toast.LENGTH_LONG); } else { // ERROR! toast = Toast.makeText(getApplicationContext(), "Error! " + response.toString(), Toast.LENGTH_LONG); } toast.show(); finish(); } }); Bundle requestParams = photoRequest.getParameters(); requestParams.putString("message", message); photoRequest.setParameters(requestParams); Request.executeBatchAsync(photoRequest); } </code></pre> <p>Some considerations:</p> <ul> <li>The picture is valid and visible</li> <li>Facebook SDK is at the latest version (3.0.2)</li> <li>I'm working on real device, with API level 8</li> <li>In the Facebook Dev's Application page, I set the fields this way: <ul> <li>Package Name: <code>com.ale.upmap</code> (the app's namespace)</li> <li>Class name: <code>com.ale.upmap.FacebookActivity</code> </li> </ul></li> <li>Application has photo_upload permission enabled</li> </ul> <p>Question: do I need to set permissions on the code too? Isn't it automatic? Also I didn't see any examples that use this method...</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