Reputation: 37
I try to share an file I downloaded. I put that file in the Ti.Filesystem.externalStorageDirectory
. The file is saved correctly since i can show it in an ImageView.image
.
Here's the code I use to start a android share intent: (apparently you can not use the file:// scheme with android API 24. See this post: stackoverflow)
filePath = filePath.replace('file','content');
var intent = Ti.Android.createIntent({
action: Ti.Android.ACTION_SEND,
});
intent.putExtraUri(Ti.Android.EXTRA_STREAM, filePath);
$.FileList.activity.startActivity(intent);
What happens is, the share dialog opens, I choose the app I wish to share to, but then I get a notice there is nothing to share.
Screenshot of failed notification:
Upvotes: 1
Views: 647
Reputation: 37
actually it was quite simple:
the working code would be:
var intent = Ti.Android.createIntent({
action: Ti.Android.ACTION_SEND,
type: '*/*'
});
intent.putExtraUri(Ti.Android.EXTRA_STREAM, filePath);
$.FileList.activity.startActivity(intent);
Upvotes: 0
Reputation: 11
try with this:
var Blob = $.container.toImage();
var file = Ti.Filesystem.getFile(Titanium.Filesystem.externalStorageDirectory, 'image_1.png');
f.write(Blob);
/// NOT HERE --filePath = filePath.replace('file','content');
var intent = Ti.Android.createIntent({
action: Ti.Android.ACTION_SEND
});
intent.putExtraUri(Ti.Android.EXTRA_STREAM, f.filePath);
////$.FileList.activity.startActivity(intent);
Ti.Android.currentActivity.startActivity(intent);
Upvotes: 1