Sending byte[] data to an activity without creating a file
I have developed an android application which takes a picture, calls a web services and sends both documents (the picture and web service response) with ACTION_SEND_MULTIPLE
intent. This action requires the data to be passed as an ArrayList<? extends Parcelable>
; Therefore the application stores the data in temporary files and creates two Uri
objects from these files. The main drawback is that the application cannot delete these temporary files since it is not possible to determine if the called activity handled the data.
Is it possible to send data (开发者_JS百科byte[]
data type) with an ACTION_SEND
or ACTION_SEND_MULTIPLE
without creating temporary files?
Thanks
of course! if suppose you have data in byte [] data, you can do it like this.
Intent i = new Intent(Intent.ACTION_SEND) ;
i.setType("your mime type here");
i.putExtra(Intent.EXTRA_STREAM, data);
startActivity(Intent.createChooser(i,"Send this To:"));
精彩评论