title: Share photo with description from android application to facebook wall by facebook sdk
body: <p>I want to post a photo with description into facebook wall like what in "instagram".I tried many codes but they are useless, can anybody help me?
  I make connection to facebook from another activity and pass the tokens to another activity to post a photo and this is ok but the posting doesn't operate correctly!!
  I see many people on this site talk about "AsyncTask" and listeners?!</p>
  
  <pre><code> public void UploadFacebookPhoto(){
  
              SharedPreferences prefs = getApplicationContext().getSharedPreferences("facebook", MODE_PRIVATE);
              String access_token = prefs.getString("access_token", null);
              long expires = prefs.getLong("access_expires", 0);
              fb.setAccessToken(access_token);
              fb.setAccessExpires(expires);
  
                  if(access_token != null) {
                      fb.setAccessToken(access_token);
                      Toast.makeText(this, "facebook", Toast.LENGTH_SHORT).show();
                   }
                   if(expires != 0) {
                      fb.setAccessExpires(expires);
                      Toast.makeText(this, "facebook1", Toast.LENGTH_SHORT).show();
                   }
                   if (! fb.isSessionValid()) {
                      Toast.makeText(this, "facebook2", Toast.LENGTH_SHORT).show();
                   }
                   if (fb.isSessionValid()) {
                          Toast.makeText(this, "valid1", Toast.LENGTH_SHORT).show();
                     fb.authorize(HomeActivity.this, new String[]{ "publish_stream"},new DialogListener() {
                           @Override                     
                           public void onComplete(Bundle values) {
                               postToWall(values.getString(Facebook.TOKEN)); 
                               }                      
                           @Override                     
                           public void onFacebookError(FacebookError error) {
                           }                      
                           @Override                     
                           public void onError(DialogError e) {
                           }                      
                           @Override                     
                           public void onCancel() {
  
                           }                 
                       });
                   }
          }
  
         private void postToWall(String accessToken) {  
  
              Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.flower);
              ByteArrayOutputStream stream = new ByteArrayOutputStream();
              bmp.compress(Bitmap.CompressFormat.PNG, 100, stream);
              byte[] data = stream.toByteArray();
  
              Bundle params = new Bundle();
              params.putString(Facebook.TOKEN, fb.getAccessToken());
              params.putString("caption", "flower");
              params.putByteArray("picture", data);
              try {
                  fb.request("me/photos", params, "POST");
  
              } catch (FileNotFoundException fileNotFoundException) {
                  Toast.makeText(HomeActivity.this,fileNotFoundException.getMessage(),Toast.LENGTH_LONG).show();
              } catch (MalformedURLException malformedURLException) {
                  Toast.makeText(HomeActivity.this,malformedURLException.getMessage(),Toast.LENGTH_LONG).show();
              } catch (IOException ioException) {
                  Toast.makeText(HomeActivity.this,ioException.getMessage(),Toast.LENGTH_LONG).show();
              }
          }//method
  </code></pre>