locked
Issue with the Search Charm RRS feed

  • Question

  • I have my Windows Store app which integrates with the search charm. It is actually very simple since the start screen has a search box qnd the second page has a grid with results. If my app is not running and I activate it from the search charm it behaves as expected navigating to my results page.

    But if my app is not active (not running at all) and I call it from the search charm, the app does not navigate to my results page. It just loads up the first page.

    This is a little bit of the important code widh I have in my default.js file.

    app.onactivated = function (eventObject) {
    	setConnectivity();
    	Windows.UI.Notifications.TileUpdateManager.createTileUpdaterForApplication().enableNotificationQueue(true);
    	Utils.log('activated: ' + eventObject.detail.kind);
    	if (eventObject.detail.kind === Windows.ApplicationModel.Activation.ActivationKind.launch)
    		displayExtendedSplash(eventObject);
    	this.eventObject = eventObject;
    	initialize.call(this);
    };
    
    function initialize() {
    	var eventObject = this.eventObject;
    	Utils.log('initialized: ' + eventObject.detail.kind);
    	if (eventObject.detail.kind === Windows.ApplicationModel.Activation.ActivationKind.launch) {
    		WinJS.UI.processAll();
    	}else if (eventObject.detail.kind === Windows.ApplicationModel.Activation.ActivationKind.search) {
    		eventObject.setPromise(WinJS.UI.processAll().then(function () {
    			var url = '';
    			if (eventObject.detail.queryText === "") {
    				url = '/html/Goomez_Level_Detail.html';
    			} else {
    				url = '/html/Results_Level_Detail.html';
    			}
    			return WinJS.Navigation.navigate(url, { searchDetails: eventObject.detail });
    		}));
    	}
    };

    this works as expected... I believe this is the piece of code that is not working and I have no idea why is that.

    Windows.ApplicationModel.Search.SearchPane.getForCurrentView().onquerysubmitted = function (eventObject) {
    	Utils.log('from search Pane: ' + eventObject.detail.kind);
    	var url = '/html/Results_Level_Detail.html';
    	WinJS.Navigation.navigate(url, { searchDetails: eventObject.detail[0] });
    };

    I based my code in the Javascript Search Contract sample.

    What am I doing wrong. Is there a way I can debug that? Keep in mind I need my app to be killed, not suspended.

    Regards


    http://about.me/sebagomez

    Thursday, May 2, 2013 6:39 PM

Answers

  • Ok, my bad... as mentioned by Girija the code is fine... the problem was I had a customControl that was "navigating" to the home page, thus, the results page was never loaded.

    So I hope the code at least will be helpfull to somebody wanting to implement search charm.

    Girija: your comment about what to do when it was a launch called my atention. You told me I should navegate to a different page, and my app is navigating so I thought "who is telling it to navigate?" and that's how I found my problem :)

    Thanks


    http://about.me/sebagomez

    Thursday, May 2, 2013 9:05 PM

All replies

  • What are you doing in displayExtendedSplash(eventObject); ?

    If you are doing any retrieval and showing the extended spash then you should dismiss it before navigating. I donot see that.

    This code :

    Windows.ApplicationModel.Search.SearchPane.getForCurrentView().onquerysubmitted = function (eventObject) {
    	Utils.log('from search Pane: ' + eventObject.detail.kind);
    	var url = '/html/Results_Level_Detail.html';
    	WinJS.Navigation.navigate(url, { searchDetails: eventObject.detail[0] });
    };

    I donot see any issue in that because you are just trying to add a event listener to get if after the app loaded the user searches. this looks fine to me as long as you are calling this in the app activated event. Just one question here : Why searchDetails: eventObject.detail[0], should not searchDetails: eventObject.detail be enough ?

    In you case if your app is killed and you start from the seach charm, the "onactivated" event will hit and it should come to the first code and not the second code.

    I am not sure but can you try this :

    app.onactivated = function (eventObject) {
    	setConnectivity();
    	Windows.UI.Notifications.TileUpdateManager.createTileUpdaterForApplication().enableNotificationQueue(true);
    	Utils.log('activated: ' + eventObject.detail.kind);
    	if (eventObject.detail.kind === Windows.ApplicationModel.Activation.ActivationKind.launch)
    		displayExtendedSplash(eventObject);
    	this.eventObject = eventObject;
    var promise = WinJS.UI.processAll();
                promise.done(function (e) {
                    initialize();
                });
    	args.setPromise(promise);
    };
    
    function initialize() {
    	var eventObject = this.eventObject;
    	Utils.log('initialized: ' + eventObject.detail.kind);
    	if (eventObject.detail.kind === Windows.ApplicationModel.Activation.ActivationKind.launch) {
    		// You should go somewhere, like home 
    //page in case the app is invoked from somewhere other 
    //than search charm
    	}else if (eventObject.detail.kind === Windows.ApplicationModel.Activation.ActivationKind.search) {
    		eventObject.setPromise(WinJS.UI.processAll().then(function () {
    			var url = '';
    			if (eventObject.detail.queryText === "") {
    				url = '/html/Goomez_Level_Detail.html';
    			} else {
    				url = '/html/Results_Level_Detail.html';
    			}
    			return WinJS.Navigation.navigate(url, { searchDetails: eventObject.detail });
    		}));
    	}
    };

    - Girija
    Thursday, May 2, 2013 7:36 PM
  • Ok, my bad... as mentioned by Girija the code is fine... the problem was I had a customControl that was "navigating" to the home page, thus, the results page was never loaded.

    So I hope the code at least will be helpfull to somebody wanting to implement search charm.

    Girija: your comment about what to do when it was a launch called my atention. You told me I should navegate to a different page, and my app is navigating so I thought "who is telling it to navigate?" and that's how I found my problem :)

    Thanks


    http://about.me/sebagomez

    Thursday, May 2, 2013 9:05 PM
  • Good to know you got it :)
    Thursday, May 2, 2013 9:10 PM