Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-12117] Android: When navBarHidden of a window is set, activity.startActivityForResult won't work

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionInvalid
Resolution Date2013-03-03T15:17:42.000+0000
Affected Version/sRelease 2.1.4, Release 3.0.0
Fix Version/sn/a
ComponentsAndroid
Labelscommunity
ReporterFederico Casali
AssigneeSunila
Created2012-12-18T12:35:01.000+0000
Updated2017-03-24T17:51:22.000+0000

Description

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();

Attachments

FileDateSize
app.js2012-12-18T12:35:01.000+00001333

Comments

  1. André Perazzi 2012-12-18

    Are you able to see the alert?
  2. André Perazzi 2012-12-20

  3. Sunila 2013-03-03

    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
  4. Lee Morris 2017-03-24

    Closing ticket as invalid with reference to the above comments.

JSON Source