How can I send an InputStream to an Activity ?

I have a RecyclerView in which content is displayed when I click on an item . In the Activity that is invoked, you need to pass the InputStream[] contained in listAttachStream .

 rv.addOnItemTouchListener( new ItemRecycler.RecyclerItemClickListener(getActivity(), new ItemRecycler.RecyclerItemClickListener.OnItemClickListener() { @Override public void onItemClick(View view, int position) { String theme = adapter.subject[position]; String content = adapter.content[position]; String date = adapter.dateMail[position]; String email = adapter.email[position]; String nameSender = adapter.from[position]; Intent intent = new Intent(getActivity(), ItemMail.class); intent.putExtra(ItemMail.SUBJECT, theme); intent.putExtra(ItemMail.CONTENT, content); intent.putExtra(ItemMail.DATE, date); intent.putExtra(ItemMail.EMAIL, email); intent.putExtra(ItemMail.NAMESENDER, nameSender); intent.putExtra(ItemMail.MAIL, "входящие"); for (int k = 0; k < listAttach.size(); k++){ for (int m = 0; m < listAttach.get(k).length; m++) { if (!(listAttach.get(k)[m] == null) && (k == position)) { intent.putExtra(ItemMail.ATTACH, listAttach.get(position)); } } } for (int k = 0; k < listAttachStream.size(); k++){ for (int m = 0; m < listAttachStream.get(k).length; m++) { if (!(listAttachStream.get(k)[m] == null) && (k == position)) { intent.putExtra(ItemMail.ATTACHSTREAM, listAttachStream.get(position)); } } } startActivity(intent); } @Override public void onItemLongPress(View childView, int position) { } }) ); 

Tried to do through Parceable - did not help. What are some ways to do this?

  • can be more detailed where to send? what you have at the moment, if you back it up with a code, it will be great in general) - ermak0ff
  • I need to send InputStream [] to Activity) - Contact
  • one
    Isn't it easier to send a position (or better id) to an activity, which itself will get everything you need? And in general, are streams in your adapter all open? And who closes them and at what point? Inaccurately somehow. - Yura Ivanov

1 answer 1

InputStream is not a serializable class, so you cannot transfer objects of this class to Activiti, but in principle you don’t need it. Typically, an InputStream is an incomplete action. That is, I mean that I use InputStream to pull up some data. If your InputStream is some kind of file or image, then you get an array of Bytes, if InputStream is text, then you get a String from it. You need to complete this work. That is, you need to get a string, or bytes, or bitmap (it depends on what you need) from your InputStream, and transfer it to Activate