Beispiel #1
0
  public static Bundle mapToBundle(Map<String, Object> map) {
    if (map == null) return new Bundle();
    Bundle bundle = new Bundle(map.size());

    for (String key : map.keySet()) {
      Object val = map.get(key);
      if (val == null) {
        bundle.putString(key, null);
      } else if (val instanceof TiBlob) {
        bundle.putByteArray(key, ((TiBlob) val).getBytes());
      } else if (val instanceof TiBaseFile) {
        try {
          bundle.putByteArray(key, ((TiBaseFile) val).read().getBytes());
        } catch (IOException e) {
          Log.e(
              "FacebookModule-Util",
              "Unable to put '" + key + "' value into bundle: " + e.getLocalizedMessage(),
              e);
        }
      } else {
        bundle.putString(key, TiConvert.toString(val));
      }
    }

    return bundle;
  }
Beispiel #2
0
  /**
   * Saves the encryption data in a bundle. Expected to be called when an Activity saves its state
   * before being sent to the background.
   *
   * <p>The IV *could* go into the first block of the payload. However, since the staleness of the
   * data is determined by whether or not it's able to be decrypted, the IV should not be read from
   * it.
   *
   * @param outState The data bundle to store data into.
   */
  public void saveToBundle(Bundle outState) {
    CipherData data = getCipherData(false);
    if (data == null) return;

    byte[] wrappedKey = data.key.getEncoded();
    if (wrappedKey != null && data.iv != null) {
      outState.putByteArray(BUNDLE_KEY, wrappedKey);
      outState.putByteArray(BUNDLE_IV, data.iv);
    }
  }
Beispiel #3
0
  public Bundle getBundle() {
    Bundle bundle = new Bundle();

    // add description
    if (mName != null) {
      bundle.putString(MESSAGE, mName);
    }

    // add place
    if (mPlaceId != null) {
      bundle.putString(PLACE, mPlaceId);
    }

    // add privacy
    if (mPrivacy != null) {
      bundle.putString(PRIVACY, mPrivacy.getJSONString());
    }

    // add image
    if (mParcelable != null) {
      bundle.putParcelable(PICTURE, mParcelable);
    } else if (mBytes != null) {
      bundle.putByteArray(PICTURE, mBytes);
    }

    return bundle;
  }
  @Override
  protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);

    /*
     * outState.putParcelable("newUID",
     * editNewUID.onSaveInstanceState()); outState.putParcelable(
     * "newEmail", editNewEmail.onSaveInstanceState());
     * outState.putParcelable( "newPass",
     * editNewPassword.onSaveInstanceState()); outState.putParcelable(
     * "repeatPass", editRetypeNewPassword.onSaveInstanceState());
     * outState.putParcelable( "newNickname",
     * editNewNickname.onSaveInstanceState());
     * outState.putParcelable("studID",
     * editStudID.onSaveInstanceState()); outState.putParcelable(
     * "realname", editRealName.onSaveInstanceState());
     * outState.putParcelable("phone", editPhone.onSaveInstanceState());
     * outState.putParcelable("captcha",
     * editCaptcha.onSaveInstanceState());
     */

    // captcha image
    ByteArrayOutputStream captchaOutStream = new ByteArrayOutputStream();
    Bitmap captchaBitmap = ((BitmapDrawable) imageRegCaptcha.getDrawable()).getBitmap();
    captchaBitmap.compress(CompressFormat.PNG, 100, captchaOutStream);

    outState.putByteArray("captchaImage", captchaOutStream.toByteArray());
  }
 /**
  * Add extended data to the extra.
  *
  * @param name The name of the extra data, with package prefix.
  * @param value The byte array data value.
  * @return Returns the same extra object, for chaining multiple calls into a single statement.
  * @see #putExtras
  * @see #removeExtra
  * @see #getByteArrayExtra(String)
  */
 public Request putExtra(String name, byte[] value) {
   if (mExtras == null) {
     mExtras = new Bundle();
   }
   mExtras.putByteArray(name, value);
   return this;
 }
 public static ScannedAmiiboFragment newInstance(byte[] data) {
   ScannedAmiiboFragment fragment = new ScannedAmiiboFragment();
   Bundle args = new Bundle();
   args.putByteArray(DATA_SCANNED, data);
   fragment.setArguments(args);
   return fragment;
 }
 public void onConnecting(DeviceInfo device, byte[] token) {
   Message m = Message.obtain(null, MsgId.CONNECTING);
   Bundle b = Utils.device2Bundle(device);
   b.putByteArray(Router.MsgKey.AUTHENTICATION_TOKEN, token);
   m.setData(b);
   recvMsg(m);
 }
 public static WebViewFragment newInstance(String url, byte[] postData) {
   WebViewFragment fragment = new WebViewFragment();
   Bundle args = new Bundle();
   args.putString(KEY_URL, url);
   args.putByteArray(KEY_POST_DATA, postData);
   fragment.setArguments(args);
   return fragment;
 }
 private static void bundleThumbnail(PlanarYUVLuminanceSource source, Bundle bundle) {
   int[] pixels = source.renderThumbnail();
   int width = source.getThumbnailWidth();
   int height = source.getThumbnailHeight();
   Bitmap bitmap = Bitmap.createBitmap(pixels, 0, width, width, height, Bitmap.Config.ARGB_8888);
   ByteArrayOutputStream out = new ByteArrayOutputStream();
   bitmap.compress(Bitmap.CompressFormat.JPEG, 50, out);
   bundle.putByteArray(DecodeThread.BARCODE_BITMAP, out.toByteArray());
 }
Beispiel #10
0
  private void saveClicked() {

    try {
      if (!isPassphraseSet()) {
        throw new PGPMain.GeneralException(this.getString(R.string.setAPassPhrase));
      }

      // Send all information needed to service to edit key in other thread
      Intent intent = new Intent(this, ApgService.class);

      intent.putExtra(ApgService.EXTRA_ACTION, ApgService.ACTION_SAVE_KEYRING);

      // fill values for this action
      Bundle data = new Bundle();
      data.putString(ApgService.CURRENT_PASSPHRASE, mCurrentPassPhrase);
      data.putString(ApgService.NEW_PASSPHRASE, mNewPassPhrase);
      data.putSerializable(ApgService.USER_IDS, getUserIds(mUserIdsView));
      Vector<PGPSecretKey> keys = getKeys(mKeysView);
      data.putByteArray(ApgService.KEYS, PGPConversionHelper.PGPSecretKeyListToBytes(keys));
      data.putSerializable(ApgService.KEYS_USAGES, getKeysUsages(mKeysView));
      data.putLong(ApgService.MASTER_KEY_ID, getMasterKeyId());

      intent.putExtra(ApgService.EXTRA_DATA, data);

      // show progress dialog
      mSavingDialog =
          ProgressDialogFragment.newInstance(
              R.string.progress_saving, ProgressDialog.STYLE_HORIZONTAL);

      // Message is received after saving is done in ApgService
      ApgHandler saveHandler =
          new ApgHandler(this, mSavingDialog) {
            public void handleMessage(Message message) {
              // handle messages by standard ApgHandler first
              super.handleMessage(message);

              if (message.arg1 == ApgHandler.MESSAGE_OKAY) {
                finish();
              }
            };
          };

      // Create a new Messenger for the communication back
      Messenger messenger = new Messenger(saveHandler);
      intent.putExtra(ApgService.EXTRA_MESSENGER, messenger);

      mSavingDialog.show(getSupportFragmentManager(), "dialog");

      // start service with intent
      startService(intent);
    } catch (PGPMain.GeneralException e) {
      Toast.makeText(this, getString(R.string.errorMessage, e.getMessage()), Toast.LENGTH_SHORT)
          .show();
    }
  }
 @Override
 public void onSaveInstanceState(Bundle savedState) {
   // We do not save view hierarchy, as they are just profiles.
   if (mDialog != null) {
     VpnProfile profile = mDialog.getProfile();
     savedState.putString("VpnKey", profile.key);
     savedState.putByteArray("VpnProfile", profile.encode());
     savedState.putBoolean("VpnEditing", mDialog.isEditing());
   }
   // else?
 }
 public static void putObjectInBundle(Bundle bundle, String key, Object value) {
   if (value instanceof String) {
     bundle.putString(key, (String) value);
   } else if (value instanceof Parcelable) {
     bundle.putParcelable(key, (Parcelable) value);
   } else if (value instanceof byte[]) {
     bundle.putByteArray(key, (byte[]) value);
   } else {
     throw new FacebookException("attempted to add unsupported type to Bundle");
   }
 }
Beispiel #13
0
  @Override
  public void writeToParcel(Parcel dest, int flags) {
    Bundle bundle = new Bundle();

    bundle.putString(FULL_NAME, getFullName());
    bundle.putString(TAG_LINE, getTagLine());
    bundle.putString(USER_ID, getUserId());
    bundle.putByteArray(USER_PHOTO_FILE, getUserPhotoByteArray());

    dest.writeBundle(bundle);
  }
 @Override
 public void onSubChanged(byte[] pixels, int width, int height) {
   Message msg = new Message();
   Bundle b = new Bundle();
   b.putByteArray(VP.SUB_PIXELS_KEY, pixels);
   b.putInt(VP.SUB_WIDTH_KEY, width);
   b.putInt(VP.SUB_HEIGHT_KEY, height);
   msg.setData(b);
   msg.what = SUBTITLE_BITMAP;
   mSubHandler.sendMessage(msg);
 }
  @Override
  protected void read(SelectionKey pKey) throws IOException, ClientDoesNotExist {
    DatagramChannel socketChannel;
    InetSocketAddress address;
    String connectionIP;
    socketChannel = (DatagramChannel) pKey.channel();
    address = (InetSocketAddress) socketChannel.receive(this.readBuffer);
    connectionIP = address.getAddress().getHostAddress();
    this.readBuffer.clear();

    // Attempt to read off the channel
    int numRead = -1;
    try {
      numRead = socketChannel.read(this.readBuffer);
    } catch (AsynchronousCloseException e) {
      log.error("AsynchronousCloseException", e);
      this.handleConnectionFailure(pKey, socketChannel, address.getAddress());
    } catch (NotYetConnectedException e) {
      log.error("NotYetConnectedException", e);
      this.handleConnectionFailure(pKey, socketChannel, address.getAddress());
    } catch (ClosedChannelException e) {
      log.error("ClosedChannelException", e);
      this.handleConnectionFailure(pKey, socketChannel, address.getAddress());
      this.removeClient(address.getAddress());
    } catch (IOException e) {
      log.error("IOException", e);
      // The remote forcibly closed the connection, cancel
      // the selection key and close the channel.
      this.handleConnectionFailure(pKey, socketChannel, address.getAddress());
      return;
    }

    if (numRead == -1) {
      // Remote entity shut the socket down cleanly. Do the
      // same from our end and cancel the channel.
      /* TODO check that closing socketChannel is ok,
       * we were doing pKey.channel().close()
       */
      this.handleConnectionShutdown(pKey, socketChannel, address.getAddress());
      return;
    }

    byte[] dataIn = new byte[numRead];
    System.arraycopy(this.readBuffer.array(), 0, dataIn, 0, numRead);

    Message msg = this.mCallerThreadHandler.obtainMessage();
    msg.what = ITCFlags.UDP_INCOMMING;
    Bundle data = new Bundle();
    data.putString("ip", connectionIP);
    data.putByteArray("data", dataIn);
    msg.setData(data);
    this.mCallerThreadHandler.sendMessage(msg);
  }
    @Override
    public void run() {
      isRunning = true;
      byte[] buffer = new byte[1024];
      int bytes;

      //			Log.v(TAG, "Receiving data from device.");
      while (true) {
        // Break out if this was cancelled.
        if (cancelled) {
          break;
        }

        try {
          bytes = this.inputStream.read(buffer);
          if (!this.isConnected) {
            mThreadHandler.sendEmptyMessage(MSG_CONNECTED);
            pushQueuedBytes();
          }
          this.isConnected = true;

          if (bytes > 0) {
            byte[] newBytes = new byte[bytes];
            for (int i = 0; i < bytes; i++) {
              newBytes[i] = buffer[i];
            }

            // Call the bytes recieved handler.
            // This call is ran in the main thread.
            Bundle data = new Bundle();
            data.putByteArray("bytes", newBytes);

            Message msg = new Message();
            msg.what = MSG_BYTES_RECEIVED;
            msg.setData(data);

            mThreadHandler.sendMessage(msg);
          }

          // Lost the connection for some reason.
        } catch (IOException e1) {
          if (!this.cancelled) {
            mThreadHandler.sendEmptyMessage(MSG_CONNECTION_LOST);
          }
          break;
        }
      }

      //			Log.v(TAG, "Stopped receiving data from device.");
      isRunning = false;
    }
  /** 银联充值跳转到插件 */
  public void turnYinView(String info) {
    // 向插件提交3要素报文
    // *********************************************************************************//

    byte[] to_upomp = info.getBytes();

    Bundle mbundle = new Bundle();
    // to_upomp为商户提交的XML
    mbundle.putByteArray("xml", to_upomp);
    // 注:此处的action是:商户的action
    mbundle.putString("action_cmd", CMD_PAY_PLUGIN);

    PluginHelper.LaunchPlugin(this, mbundle);
  }
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    switch (requestCode) {
        /*
         * if this is the activity result from authorization flow, do a call
         * back to authorizeCallback Source Tag: login_tag
         */
      case AUTHORIZE_ACTIVITY_RESULT_CODE:
        {
          Utility.mFacebook.authorizeCallback(requestCode, resultCode, data);
          break;
        }
        /*
         * if this is the result for a photo picker from the gallery, upload
         * the image after scaling it. You can use the Utility.scaleImage()
         * function for scaling
         */
      case PICK_EXISTING_PHOTO_RESULT_CODE:
        {
          if (resultCode == Activity.RESULT_OK) {
            Uri photoUri = data.getData();
            if (photoUri != null) {
              Bundle params = new Bundle();
              try {
                params.putByteArray("photo", Utility.scaleImage(getApplicationContext(), photoUri));
              } catch (IOException e) {
                e.printStackTrace();
              }
              params.putString("caption", "FbAPIs Sample App photo upload");
              Utility.mAsyncRunner.request(
                  "me/photos", params, "POST", new PhotoUploadListener(), null);
            } else {
              Toast.makeText(
                      getApplicationContext(),
                      "Error selecting image from the gallery.",
                      Toast.LENGTH_SHORT)
                  .show();
            }
          } else {
            Toast.makeText(
                    getApplicationContext(), "No image selected for upload.", Toast.LENGTH_SHORT)
                .show();
          }
          break;
        }
    }
  }
Beispiel #19
0
  @Override
  public void run() {

    while (true) {
      try {
        int res = 0;
        int size = 0;
        while (size == 0) {
          byte sizeData[] = new byte[4];
          res = inputStream.read(sizeData);
          size =
              ((((sizeData[3] & 0xff) << 24)
                  | ((sizeData[2] & 0xff) << 16)
                  | ((sizeData[1] & 0xff) << 8)
                  | ((sizeData[0] & 0xff) << 0)));
        }
        byte data[] = new byte[size];
        int isRead = 0;
        byte buffer[] = new byte[1024];
        while (isRead < size) {
          res = inputStream.read(buffer, 0, buffer.length);
          System.arraycopy(buffer, 0, data, isRead, res);
          isRead += res;
        }
        MessageEntity message = MessageEntity.parseFrom(data);

        Log.d(
            "Message Download",
            message.getMessageHead() + " " + message.getMessagePayload().size());

        if (message.getMessageID() != 0) {
          Message msg = new Message();
          msg.what = message.getMessageType();
          Bundle bundle = new Bundle();
          bundle.putByteArray("messageData", message.toByteArray());
          bundle.putString("address", mSocket.getInetAddress().getHostAddress());
          msg.setData(bundle);
          mHandler.sendMessage(msg);
          TCPServer.downloaders.remove(this);
          finish();
          break;
        }

      } catch (IOException e) {
        e.printStackTrace();
      }
    }
  }
  // 把对应Cursor里数据拿出来 装进一个bundle 通过Intent带值传递
  private Bundle getCursorData(Cursor cursor) {

    Bundle bundle = new Bundle();
    bundle.putInt("_id", cursor.getInt(cursor.getColumnIndex(Constant._ID)));
    bundle.putString("name", cursor.getString(cursor.getColumnIndex(Constant._NAME)));
    bundle.putString("date", cursor.getString(cursor.getColumnIndex(Constant._DATE)));
    bundle.putInt("sort", cursor.getInt(cursor.getColumnIndex(Constant._SORT)));
    bundle.putInt("mode", cursor.getInt(cursor.getColumnIndex(Constant._MODE)));
    bundle.putInt("payOrIncome", cursor.getInt(cursor.getColumnIndex(Constant._PAYORORINCOME)));
    bundle.putString("money", cursor.getString(cursor.getColumnIndex(Constant._MONEY)));
    bundle.putString("person", cursor.getString(cursor.getColumnIndex(Constant._PERSON)));
    bundle.putString("remark", cursor.getString(cursor.getColumnIndex(Constant._REMARK)));
    bundle.putByteArray("photo", cursor.getBlob(cursor.getColumnIndex(Constant._PHOTO)));

    return bundle;
  }
  /** 银联充值跳转到插件 */
  public void turnYinView(String info) {
    // 向插件提交3要素报文
    // *********************************************************************************//

    byte[] to_upomp = info.getBytes();
    ComponentName com =
        new ComponentName(
            Constants.MERCHANT_PACKAGE, "com.unionpay.upomp.lthj.plugin.ui.MainActivity");
    Intent intent = new Intent();
    intent.setComponent(com); // 启动插件(进入支付页面)
    intent.putExtra("action_cmd", CMD_PAY_PLUGIN);
    Bundle mbundle = new Bundle();
    mbundle.putByteArray("xml", to_upomp);
    mbundle.putString("merchantPackageName", MAIN_ACTION);
    intent.putExtras(mbundle);
    startActivity(intent);
  }
Beispiel #22
0
 public static Bundle a(WXMediaMessage wxmediamessage) {
   Bundle bundle = new Bundle();
   bundle.putInt("_wxobject_sdkVer", wxmediamessage.sdkVer);
   bundle.putString("_wxobject_title", wxmediamessage.title);
   bundle.putString("_wxobject_description", wxmediamessage.description);
   bundle.putByteArray("_wxobject_thumbdata", wxmediamessage.thumbData);
   if (wxmediamessage.mediaObject != null) {
     bundle.putString(
         "_wxobject_identifier_",
         (new StringBuilder())
             .append("com.tencent.mm.sdk.openapi.")
             .append(wxmediamessage.mediaObject.getClass().getSimpleName())
             .toString());
     wxmediamessage.mediaObject.serialize(bundle);
   }
   return bundle;
 }
    /**
     * Write to the connected OutStream.
     *
     * @param buffer The bytes to write
     */
    public void write(byte[] buffer) {
      try {
        mmOutStream.write(buffer);

        // Share the sent message back to the UI Activity
        /*
         * mHandler.obtainMessage(MainActivity.MESSAGE_WRITE, -1, -1,
         * buffer).sendToTarget();
         */
        Bundle bundle = new Bundle();
        bundle.putInt(BUNDLE_TYPE, OperationActivityHD.MESSAGE_WRITE);
        bundle.putByteArray("buffer", buffer);
        System.out.println("mmoutStream.write---------------->" + bundle);
        showMessage(bundle);
      } catch (IOException e) {
        Log.e(TAG, "Exception during write", e);
      }
    }
Beispiel #24
0
  public void Storage(TransportPacket p, String i) {
    try {
      packet =
          new CommandPacket(); // !!!!!!!!!!!! Sinon on peut surement en valeur les arguments des
                               // command précédantes !
      packet.parse(p.getData());

      Message mess = new Message();
      Bundle b = new Bundle();
      b.putShort("command", packet.getCommand());
      b.putByteArray("arguments", packet.getArguments());
      b.putInt("chan", packet.getTargetChannel());
      mess.setData(b);
      handler.sendMessage(mess);
    } catch (Exception e) {
      System.out.println("Androrat.Client.storage : pas une commande");
    }
  }
  private void invokeOemRilRequestRaw(byte abyte0[], Message message, Messenger messenger) {
    if (mServiceMessenger != null) {
      try {
        Bundle bundle = message.getData();
        bundle.putByteArray("request", abyte0);
        message.setData(bundle);
        message.replyTo = messenger;

        mServiceMessenger.send(message);

        SystemClock.sleep(200);
      } catch (RemoteException remoteexception) {
        Log.d(LOG_TAG, "RemoteException", remoteexception);
      }
    } else {
      Log.e(LOG_TAG, "Could not connect to phone service.");
    }
  }
Beispiel #26
0
 public static void updateTexture(
     Messenger paramMessenger,
     String paramString,
     Bitmap paramBitmap,
     boolean paramBoolean1,
     boolean paramBoolean2) {
   Bundle localBundle = new Bundle();
   localBundle.putString("shape_name", paramString);
   if (paramBitmap != null) {
     ByteArrayOutputStream localByteArrayOutputStream = new ByteArrayOutputStream();
     paramBitmap.compress(Bitmap.CompressFormat.PNG, 100, localByteArrayOutputStream);
     localBundle.putByteArray("bitmap_stream", localByteArrayOutputStream.toByteArray());
     Message localMessage = Message.obtain(null, 4);
     localMessage.setData(localBundle);
     CircleWidget3DProvider.sendMessage(paramMessenger, localMessage);
     return;
   }
   Log.e("Circle", "No Bitmap for texture");
 }
  @Override
  protected void onSaveInstanceState(Bundle outState) {
    Log.i("doTake", "onSaveInstanceState");

    int[] imgFlag = new int[1];
    // Flag initialize
    for (int i = 0; i < imgFlag.length; i++) {
      imgFlag[i] = 0;
    }

    for (int i = 0; i < 1; i++) {
      if (resized != null) {
        imgFlag[i] = 1;
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        resized.compress(Bitmap.CompressFormat.JPEG, 80, baos);
        outState.putByteArray("Bitmap" + i, baos.toByteArray());
      }
      outState.putInt("img" + i, imgFlag[i]);
    }
    super.onSaveInstanceState(outState);
  }
 private void updateSub(int subType, byte[] bytes, String encoding, int width, int height) {
   if (mEventHandler != null) {
     Message m = mEventHandler.obtainMessage(MEDIA_TIMED_TEXT, width, height);
     Bundle b = m.getData();
     if (subType == SUBTITLE_TEXT) {
       b.putInt(MEDIA_SUBTITLE_TYPE, SUBTITLE_TEXT);
       if (encoding == null) {
         b.putString(MEDIA_SUBTITLE_STRING, new String(bytes));
       } else {
         try {
           b.putString(MEDIA_SUBTITLE_STRING, new String(bytes, encoding.trim()));
         } catch (UnsupportedEncodingException e) {
           Log.e("updateSub", e);
           b.putString(MEDIA_SUBTITLE_STRING, new String(bytes));
         }
       }
     } else if (subType == SUBTITLE_BITMAP) {
       b.putInt(MEDIA_SUBTITLE_TYPE, SUBTITLE_BITMAP);
       b.putByteArray(MEDIA_SUBTITLE_BYTES, bytes);
     }
     mEventHandler.sendMessage(m);
   }
 }
  @Override
  public void post(
      final Context context,
      final Corruption corruption,
      final AccessToken accessToken,
      final OperationCallback<Integer> callback) {
    File file = new File(corruption.getMediaFilePath());

    Bundle params = new Bundle();
    params.putString(Utils.Constants.DESCRIPTION, Utils.getNarrative(context, corruption));
    params.putByteArray(corruption.getMediaFilePath(), Utils.convertFileToBytes(file));

    GraphRequest request =
        new GraphRequest(
            accessToken,
            Utils.Constants.PAGE_VIDEOS,
            params,
            HttpMethod.POST,
            new GraphRequest.Callback() {
              @Override
              public void onCompleted(GraphResponse graphResponse) {
                if (graphResponse.getError() == null) {
                  try {
                    String post_Id = graphResponse.getJSONObject().getString("id");
                    corruption.setPostId(post_Id);
                  } catch (JSONException e) {
                    Logger.log(AudioPoster.class, e.getMessage());
                  }
                  callback.performOperation(R.string.success);
                } else {
                  callback.performOperation(R.string.failed);
                }
              }
            });

    request.executeAsync();
  }
  @Override
  public void postPhoto(
      Activity parent,
      String appId,
      String link,
      String caption,
      Uri photoUri,
      SocialNetworkListener listener) {

    try {
      Bundle params = new Bundle();
      params.putString("caption", caption + ": " + link);
      params.putByteArray("photo", facebookImageUtils.scaleImage(parent, photoUri));

      Facebook fb = newFacebook(appId);

      final FacebookSessionStore store = newFacebookSessionStore();

      store.restore(fb, parent);

      AsyncFacebookRunner runner = newAsyncFacebookRunner(fb);

      RequestListener requestListener = newRequestListener(parent, listener);

      runner.request("me/photos", params, "POST", requestListener, null);
    } catch (IOException e) {
      if (listener != null) {
        listener.onError(parent, SocialNetwork.FACEBOOK, "Unable to scale image for upload", e);
      }

      if (logger != null) {
        logger.error("Unable to scale image for upload", e);
      } else {
        e.printStackTrace();
      }
    }
  }