Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code>public class CardShared extends Activity{ public static final String APP_ID = "YOUR APP ID"; private Facebook mFacebook; private AsyncFacebookRunner mAsyncRunner ; boolean isLoggedIn = false; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // setContentView(R.layout.main); mFacebook = new Facebook(APP_ID); mAsyncRunner = new AsyncFacebookRunner(mFacebook); //Implementing SSO mFacebook.authorize(this, new String[]{"publish_stream"}, new DialogListener(){ public void onComplete(Bundle values) { sharePicture(values.getString(Facebook.TOKEN)); Toast.makeText(getApplicationContext(), "Picture Shared Successfully", Toast.LENGTH_SHORT).show(); CardShared.this.finish(); } public void onFacebookError(FacebookError e) { Log.d("FACEBOOK ERROR","FB ERROR. MSG: "+e.getMessage()+", CAUSE: "+e.getCause()); } public void onError(DialogError e) { Log.e("ERROR","AUTH ERROR. MSG: "+e.getMessage()+", CAUSE: "+e.getCause()); } public void onCancel() { Log.d("CANCELLED","AUTH CANCELLED"); } }); } //updating Status public void sharePicture(String accessToken){ byte[] data = null; try { Bitmap image = BitmapFactory.decodeResource(getResources(), R.drawable.image_to_be_uploaded); ByteArrayOutputStream baos = new ByteArrayOutputStream(); image.compress(Bitmap.CompressFormat.JPEG, 100, baos); data = baos.toByteArray(); Bundle params = new Bundle(); params.putString("method", "photos.upload"); params .putString(Facebook.TOKEN, mFacebook .getAccessToken()); params.putByteArray("picture", data); mAsyncRunner.request(null, params, "POST", new SampleUploadListener(), null); } catch (Exception e) { e.printStackTrace(); } } @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); Log.d("onActivityResult","onActivityResult"); mFacebook.authorizeCallback(requestCode, resultCode, data); } public class SampleUploadListener extends BaseRequestListener { public void onComplete(final String response, final Object state) { try { Log.d("Facebook-Example", "Response: " + response.toString()); JSONObject json = Util.parseJson(response); final String f = json.getString("src"); } catch (JSONException e) { Log.w("Facebook-Example", "JSON Error in response"); } catch (FacebookError e) { Log.w("Facebook-Example", "Facebook Error: " + e.getMessage()); } } } </code></pre> <p>}</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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