IntentLauncher - How to send a file (pdf, image, etc) or another app?

Hi, I’m trying to use IntentLauncher to send a file (image, pdf, etc) to another APP.

I already send a text using

const result = await IntentLauncher.startActivityAsync('android.intent.action.SEND', {
  type: "text/plain",
  extra: {
    'android.intent.extra.TEXT': 'text to share',
  },
});

But when I do something using STREAM, this doen’t work.

// this gives me resultCode: -1, but doesnt send the file
const result = await IntentLauncher.startActivityAsync('android.intent.action.SEND', {
  type: 'image/jpeg',
  data: encodedURI
});

// none of those work
const result = await IntentLauncher.startActivityAsync('android.intent.action.SEND', {
  type: "image/jpeg",
  extra: {
    'android.intent.extra.STREAM': encodedURI,
// or
//    'android.intent.extra.STREAM': uri,
  }
});

// or
const data = await FileSystem.readAsStringAsync(encodedURI, {
  encoding: FileSystem.EncodingType.Base64,
});
const result = await IntentLauncher.startActivityAsync('android.intent.action.SEND', {
  type: "image/jpeg",
  extra: {
    'android.intent.extra.STREAM': ['data:image/jpeg;base64,', data].join(''),
  }
}); 

const result = await IntentLauncher.startActivityAsync('android.intent.action.SEND', {
  type: "image/jpeg",
  data: uri,
  // or
  //data: ['data:image/jpeg;base64,', data].join(''),
});

There is some way to SEND a file to another APP, and not just a text?

Now I’m using expo-sharing, so I can share files in iOS and Android both.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.