0

I would like to open a Text file launcher from my application. I have a byte[]/base64 data, that needs to be launch in an app based on their extension. I tried launching a text file using below code, but im unable to do so. Could any one please help me on this? Here is my code:

    Uri myUri = Uri.parse(mActionResponse.getAttachmentData()); //mActionResponse.getAttachmentData() will return byte []
    Intent intent = new Intent(Intent.ACTION_EDIT);
    intent.setDataAndType(myUri, "text/plain");
    context.startActivity(intent);

FYI i dont want to save the file in device storage.

Akeshwar Jha
  • 4,516
  • 8
  • 52
  • 91
Ravi
  • 151
  • 2
  • 13
  • You will need to use ContentProviders. This might be related - http://stackoverflow.com/questions/21304489/how-to-open-private-files-saved-to-the-internal-storage-using-intent-action-view – Sufian Jul 28 '16 at 01:32
  • Also look into [Storage Access Framework](https://developer.android.com/guide/topics/providers/document-provider.html). – Sufian Jul 28 '16 at 07:32
  • Thanks a lot for your reply. But i dont want to save the bsae64 code as a file, ma pp should launch the base64 value in device's default applications based on the extensions – Ravi Aug 04 '16 at 04:43
  • If you want to open a file (which is residing inside your app's private folder), I think you will have to use Storage Access Framework, if it is possible by any way (which I hope it is). – Sufian Aug 04 '16 at 07:03
  • Thats ok i got it. But my requirement was i will get the base64 code from ma server, once download process is done with base64, my application should launch device's default applicatoin based on the extension, for ex if my server returns jpg image as base64, once the download completes the image should open in gallery, if the base64 is a PDF content, then the base64 should open in pdf viewer etc., – Ravi Aug 05 '16 at 03:01
  • I guess you will have to convert the file to appropriate format so that the target app can understand. – Sufian Aug 05 '16 at 07:35

0 Answers0