Description of the problem
When opening an intent to share data using startActivityForResult, the result e.resultCode is always set to RESULT_CANCELED
Test code
1) Use the following code to test
2) Share an image with an external app: if you share or cancel, the result is always CANCELED
var win = Ti.UI.createWindow({
backgroundColor: 'black'
});
var btn = Ti.UI.createButton({
title: 'Share'
});
btn.addEventListener('click', function(e) {
var intent = Ti.Android.createIntent({
type: "image/jpg",
action: Ti.Android.ACTION_SEND
});
var image = Ti.Filesystem.getFile(Ti.Filesystem.externalStorageDirectory, 'image.jpg');
Ti.API.info(image.nativePath);
intent.putExtra(Ti.Android.EXTRA_SUBJECT, "Subject");
intent.putExtra(Ti.Android.EXTRA_TITLE, "Title");
intent.putExtra(Ti.Android.EXTRA_TEXT, "Text");
intent.putExtraUri(Ti.Android.EXTRA_STREAM, image.nativePath);
Ti.Android.currentActivity.startActivityForResult(Ti.Android.createIntentChooser(intent, "Share image"), function(e) {
switch(e.resultCode) {
case Ti.Android.RESULT_OK:
alert("OK"); break;
case Ti.Android.RESULT_CANCELED:
alert("CANCELED"); break;
}
});
});
win.add(btn);
win.open();
No comments