1

我正在尝试通过我的 android 应用程序在 facebook 中发布视频。但我无法完成那个。Logcat 中没有错误。在下面添加我的代码。

private void PostVdoFacebook(String review){
      mProgress.setMessage("Posting ...");
      mProgress.show();
      String response=" ";
      AsyncFacebookRunner mAsyncFbRunner = new AsyncFacebookRunner(mFacebook);
      FileInputStream is;
      Bundle params = new Bundle();
      try{
       is = new FileInputStream(getRealPathFromURI(uriVideo));
       byte[] data = readBytes(is);

      params.putByteArray("video",
        data);

     } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
     }
      params.putString("caption", review);
      mAsyncFbRunner.request("me/videos", params, "POST",
                 new PhotoUploadListener());
     }

readBytes 函数是

 public byte[] readBytes(InputStream inputStream) throws IOException {
      // This dynamically extends to take the bytes you read.
      ByteArrayOutputStream byteBuffer = new ByteArrayOutputStream();

      // This is storage overwritten on each iteration with bytes.
      int bufferSize = 1024;
      byte[] buffer = new byte[bufferSize];

      // We need to know how may bytes were read to write them to the byteBuffer.
      int len = 0;
      while ((len = inputStream.read(buffer)) != -1) {
          byteBuffer.write(buffer, 0, len);
      }

      // And then we can return your byte array.
      return byteBuffer.toByteArray();
  }
4

0 回答 0