title: TransactionTooLargeException even when file size is super small
body: <p>I keep getting this error when trying share an image file:</p>
  
  <p>java.lang.RuntimeException: android.os.TransactionTooLargeException: data parcel size 1085992 bytes</p>
  
  <p>I assumed a fix for this would be to compress the image even more and that would lessen the size. Here's the function that does this job:</p>
  
  <pre><code> public static File saveBitmaptoFile(Bitmap bitmap, File pictureFile) {
      FileOutputStream out = null;
      try {
          out = new FileOutputStream(pictureFile);
  
          // on the next line I'm trying compress the heck out of image.
          bitmap.compress(Bitmap.CompressFormat.JPEG, 1, out);
      } catch (Exception e) {
          e.printStackTrace();
      } finally {
          try {
              if (out != null) {
                  out.close();
              }
          } catch (IOException e) {
              e.printStackTrace();
          }
      }
      return pictureFile;
  }
  </code></pre>
  
  <p>Here's the share function:</p>
  
  <pre><code> private void shareToInstagram() {
          String type = "image/png";
          Intent share = new Intent(Intent.ACTION_SEND);
         //saveBitmpatoFile saves an extremely small and compressed file about 5kb in size
  
          File pictureFile = ImageUtil.saveBitmaptoFile(photo, ImageUtil.getOutputMediaFile());
          Uri imgUri = FileProvider.getUriForFile(mContext,"com.mycompany.myapp", pictureFile);
  
          share.setType(type);
          share.putExtra(Intent.EXTRA_STREAM, imgUri);
          mContext.startActivity(Intent.createChooser(share, "Share to"));
      }
  </code></pre>
  
  <p>I don't understand how, even with such extreme compression applied to the picture file, the TransactionTooLarge error still gets thrown, saying that the parcel size has effectively not changed one bit. What's more is when I select to share the file through gmail I see can that the file size is 5kb; I'm way below the buffer size of 1000kb sited in the docs! Anybody knows what could be causing this error to still be getting thrown?</p>
  
  <p>Error log:</p>
  
  <pre><code>E/JavaBinder: !!! FAILED BINDER TRANSACTION !!!  (parcel size = 1085992)
  W/ActivityThread: Bundle stats:
  W/ActivityThread:   android:viewHierarchyState [size=3192]
  W/ActivityThread:     android:views [size=3088]
  W/ActivityThread:   android:support:fragments [size=5516]
  W/ActivityThread: PersistableBundle stats:
  W/ActivityThread:   [null]
  D/AndroidRuntime: Shutting down VM
  E/AndroidRuntime: FATAL EXCEPTION: main
                Process: com.myCompany.myApp, PID: 6837
                java.lang.RuntimeException: android.os.TransactionTooLargeException: data parcel size 1085992 bytes
                    at android.app.ActivityThread$StopInfo.run(ActivityThread.java:3950)
                    at android.os.Handler.handleCallback(Handler.java:790)
                    at android.os.Handler.dispatchMessage(Handler.java:99)
                    at android.os.Looper.loop(Looper.java:164)
                    at android.app.ActivityThread.main(ActivityThread.java:6494)
                    at java.lang.reflect.Method.invoke(Native Method)
                    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
                    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
                 Caused by: android.os.TransactionTooLargeException: data parcel size 1085992 bytes
                    at android.os.BinderProxy.transactNative(Native Method)
                    at android.os.BinderProxy.transact(Binder.java:764)
                    at android.app.IActivityManager$Stub$Proxy.activityStopped(IActivityManager.java:4623)
                    at android.app.ActivityThread$StopInfo.run(ActivityThread.java:3934)
                    at android.os.Handler.handleCallback(Handler.java:790) 
                    at android.os.Handler.dispatchMessage(Handler.java:99) 
                    at android.os.Looper.loop(Looper.java:164) 
                    at android.app.ActivityThread.main(ActivityThread.java:6494) 
                    at java.lang.reflect.Method.invoke(Native Method) 
                    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) 
                    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807) 
  E/UncaughtException: java.lang.RuntimeException: android.os.TransactionTooLargeException: data parcel size 1085992 bytes
                       at android.app.ActivityThread$StopInfo.run(ActivityThread.java:3950)
                       at android.os.Handler.handleCallback(Handler.java:790)
                       at android.os.Handler.dispatchMessage(Handler.java:99)
                       at android.os.Looper.loop(Looper.java:164)
                       at android.app.ActivityThread.main(ActivityThread.java:6494)
                       at java.lang.reflect.Method.invoke(Native Method)
                       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
                    Caused by: android.os.TransactionTooLargeException: data parcel size 1085992 bytes
                       at android.os.BinderProxy.transactNative(Native Method)
                       at android.os.BinderProxy.transact(Binder.java:764)
                       at android.app.IActivityManager$Stub$Proxy.activityStopped(IActivityManager.java:4623)
                       at android.app.ActivityThread$StopInfo.run(ActivityThread.java:3934)
                       at android.os.Handler.handleCallback(Handler.java:790) 
                       at android.os.Handler.dispatchMessage(Handler.java:99) 
                       at android.os.Looper.loop(Looper.java:164) 
                       at android.app.ActivityThread.main(ActivityThread.java:6494) 
                       at java.lang.reflect.Method.invoke(Native Method) 
                       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) 
                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807) 
  </code></pre>