Problem descrption
When trying to use activity.startActivityForResult on Android, if the window's property "navBarHidden" is set, the function argument of the method is not called.
In that case, there is no way to reach the intent's return.
Steps to reproduce
- Run the sample code
- Click on the Crop button to crop and save a picture in the gallery
Expected result: lines 32 and 33 of the code should be triggered, but they are not.
Commenting out 'navBarHidden' property of the window it works as expected.
curWin = Ti.UI.createWindow({
backgroundColor:'#ffffff',
navBarHidden:true, // IF THIS IS ENABLED THE startActivityForResult WONT WORK
exitOnClose:true
});
var myView = Ti.UI.createView();
var curBtn = Ti.UI.createButton({
color:'#000000',
title:'Start Crop',
height:'auto',
width:'auto'
});
myView.add(curBtn);
curBtn.addEventListener('click', function(e) {
try{
Titanium.Media.openPhotoGallery({
success : function(event) {
var intent = Ti.Android.createIntent({
action: "com.android.camera.action.CROP",
data: event.media.nativePath,
type: 'image/*'
});
intent.putExtra("outputX", 512);
intent.putExtra("outputY", 1024);
intent.putExtra("aspectX", 1);
intent.putExtra("aspectY", 2);
intent.putExtra("scale", true);
var activity = Ti.Android.currentActivity;
activity.startActivityForResult(intent, function(param){
alert(JSON.stringify(param.intent));
Ti.API.info('#### activity')
});
},
error:function(error)
{ },
cancel : function()
{ }
});
}
catch(e)
{ }
});
curWin.add(myView);
curWin.open();
Are you able to see the alert?
setting the property 'navBarHidden' in createWindow will create a new Activity and js context. The code Ti.Android.currentActivity here, refers to the app main activity and the callback won't get called until that activity is active. To use the activity for the 'curWin', use 'curWin.getActivity()' instead of Ti.Android.currentActivity which will fix the problem
Closing ticket as invalid with reference to the above comments.