tray icon indicating copy to clipboard operation
tray copied to clipboard

Values as InputStreams

Open stephanenicolas opened this issue 9 years ago • 3 comments

Hi Tray team,

What do you think of adding the ability to read an input stream from a tray item and write to a tray item using an outputstream ? (Ideally there would be no transformation of the binary stream to get higher speed levels).

Actually, it would help to serialize and parse Pojos encoded with whatever format devs want (I would use it for JSON, but protobuf would also work, etc..)

thanks for your efforts on this lib guys !

stephanenicolas avatar Jul 07 '15 18:07 stephanenicolas

No transformation of the binary stream for more speed is impossible. tl;dr Everything needs to be passed to a different process. Please read this for more infos about Binder and the ContentProvider.

Another thing: Tray isn't fast (and it will never be fast) by design. If you want something fast use the SharedPreferences but you will lose the multiprocess support. That in mind, it is properly not a good idea to store complex data structures in Tray unless it is very important for the data to stay in sync and persisted between different processes. Otherwise it would be a better idea to use a seperate database or a simple file for the data.

There is also a Binder limitation of ~2mb per transaction (visible in logcat as !!! FAILED BINDER TRANSACTION !!!). This means you can't save unlimited data per key.

But I see some cases where persisting a byte[] or a stream could be useful. I hope it does not get abused :unamused:.

passsy avatar Jul 15 '15 18:07 passsy

Thx a lot @Pascal Welsch for the details. Though Tray is not what we are looking for, I wish you good luck with your lib.

2015-07-15 11:02 GMT-07:00 Pascal Welsch [email protected]:

No transformation of the binary stream for more speed is impossible. tl;dr Everything needs to be passed to a different process. Please read this https://github.com/grandcentrix/tray/issues/28#issuecomment-108282253 for more infos about Binder and the ContentProvider.

Another thing: Tray isn't fast (and it will never be fast) by design. If you want something fast use the SharedPreferences but you will lose the multiprocess support. That in mind, it is properly not a good idea to store complex data structures in Tray unless it is very important for the data to stay in sync and persisted between different processes. Otherwise it would be a better idea to use a seperate database or a simple file for the data.

There is also a Binder limitation of ~2mb per transaction (visible in logcat as !!! FAILED BINDER TRANSACTION !!!). This means you can't save unlimited data per key.

But I see some cases where persisting a byte[] or a stream could be useful. I hope it does not get abused [image: :unamused:].

— Reply to this email directly or view it on GitHub https://github.com/grandcentrix/tray/issues/33#issuecomment-121694718.

stephanenicolas avatar Jul 15 '15 19:07 stephanenicolas

@stephanenicolas What about the library you looking for? Did you find it。Thx

ronanhardiman avatar Sep 14 '16 06:09 ronanhardiman