Shifting to next screen from Titanium.Media.openPhotoGallery

You must Login before you can answer or comment on any questions.

Hi all,

I am using titanium to make a small app where i can click on a 'gallery' button on a window and it opens photogallery. On selecting the photo it should move to next window. But what it does is, it closes the photogallery first, after that i can see my first(button) screen and then it opens the next window.

I dont want it to show the previous window. Is there a way to do it??

I am adding windows to tabs . Below is my code .

cameraButton.addEventListener('click',function(e){
                chooseImageFromGallery();
            }); 
 
 
 
    function chooseImageFromGallery(){
 
            var capturedImg;
 
            //TODO     Titanium.Media.showCamera({
            Titanium.Media.openPhotoGallery({
                success : function(event) {
 
                    capturedImg = event.media;
 
                    /* Condition to check the selected media */
                    if (event.mediaType == Ti.Media.MEDIA_TYPE_PHOTO) {
                            var window1 = MyWindows.init(capturedImg, docImgModel, previous_win);
 
                                    MyCommon.addWindowToTabGroup(window1);
                            win.close();
                    }
                },
                cancel : function() {
                    //While cancellation of the process
                    activityInd.hide();
                            win.remove(activityInd);
                },
                error : function(error) {
                    /* called when there's an error */
                    var a = Titanium.UI.createAlertDialog({
                        titleid : 'camera'
                    });
                    if (error.code == Titanium.Media.NO_CAMERA) {
                        a.setMessage(L('camera_not_available'));
                    } else {
                        a.setMessage('Unexpected error: ' + error.message);
                    }
                    a.show();
                    activityInd.hide();
                    win.remove(activityInd);
 
                }
            });
 
        }
The init method just creates a new window and returns it .

    The addWindowToTabGroup method adds it to the current tab<CODEBLOCK javascript>        addWindowToTabGroup(window){
            // tabGroup is a tab at global level declared in app.js
            // activeTab returns the current tab
            tabGroup.activeTab.open(window, {
                        animated : true
                      });
        }

</CODEBLOCK>

Thanks a lot

— asked 9 months ago by Karanveer Sodhi
3 Comments
  • there was an error while posting . I am pasting the messed up code below

    addWindowToTabGroup(window){
                // tabGroup is a tab at global level declared in app.js
                // activeTab returns the current tab
                tabGroup.activeTab.open(window, {
                            animated : true
                          });
            }

    — commented 9 months ago by Karanveer Sodhi

  • Karanveer, i think you want to display that image in new new window right?

    — commented 9 months ago by Ritesh .

  • Yes, a new window but that will be added to the tab group . And its working fine . but the issue is that it closes the photogallery, which reveals the previous window for a short amount of time and then moves to next window. I don't want that to happen ...

    — commented 9 months ago by Karanveer Sodhi

Your Answer

Think you can help? Login to answer this question!