Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
Sanjit_Patra
Posts: 148
Registered: ‎01-08-2013
My Device: 9860

Application goes from foreground to background which function is called

Hi All,

   I want to know which function is called when application goes from foreground to background. Please help me.

 

Thans & Regards

   Sanjit

Developer
ekke
Posts: 1,563
Registered: ‎04-08-2010
My Device: Z10 (red Limited Edition), Q10, Z30
My Carrier: Telekom.de, O2, Vodafone

Re: Application goes from foreground to background which function is called

onThumnailed()

https://developer.blackberry.com/cascades/reference/bb__application.html#function-thumbnail

-------------------------------------------------------------------------------
ekke (independent software architect, rosenheim, germany)

BlackBerry Elite Developer
BlackBerry Platinum Enterprise Partner
International Development Mobile Apps BlackBerry 10 Cascades
Cascades - Workshops / Trainings / Bootcamps

blog: http://ekkes-corner.org videos: http://www.youtube.com/user/ekkescorner http://vimeo.com/ekkescorner/videos
bb10-development: http://appbus.org Twitter: @ekkescorner
Developer
sorout2009
Posts: 104
Registered: ‎08-23-2012
My Device: Blackberry Z10

Re: Application goes from foreground to background which function is called

When Apps goes from Foreground to Background, onThumbnailed is called but while the App comes in Foreground from Background, onFullScreened is called.

 

Press like if this solve your problem and also mark as solved.

Dharmender Singh
Developer
slashkyle
Posts: 820
Registered: ‎10-16-2012
My Device: Red Z10

Re: Application goes from foreground to background which function is called

[ Edited ]

if you're comfortable working with c++ you can get a much more reliable version using the bps monitor found in this sample 

 

and these c++ files will save you from having to create the navigator service.

just throw them into your src folder.

if you get stuck,check the original sample & look for anything that initiates virtualkeyboard service & immitate it with navigatorservice

 

main.cpp

#include "BPSMonitor.h"
#include "NavigatorService.h"



Q_DECL_EXPORT int main(int argc, char **argv) { const char *uri = "bb.cascades.bps"; qmlRegisterType<bb::cascades::bps::BPSMonitor>(uri, 1, 0, "BPSMonitor"); qmlRegisterInterface<bb::cascades::bps::BlackBerryPlatformService>("BlackBerryPlatformService"); qmlRegisterType<bb::cascades::bps::NavigatorService>(uri, 1, 0, "NavigatorService"); Application app(argc, argv); // Create the Application UI object, this is where the main.qml file // is loaded and the application scene is set. new ApplicationUI(&app); // Enter the application main event loop. return Application::exec(); }

 

 

then in qml

 

attachedObjects: [
        BPSMonitor {
            id: bpsMonitor
            //Receive events when the navigator becomes visible or hides
            navigatorService: NavigatorService {
                id: navigatorService
                onNavWinStateIs: {
                    if (state == 0){
                        console.log("Application FullScreen");
//place window fullscreen code here } else if (state == 1) { console.log("Application Thumbnailed");
//place window thumbnailed code here } else { console.log("Application Hidden");
//place window hidden code here } } onNavigatorHidden: { zoomer.value = 0; loadingImage.translationX = 0; loadingImage.visible = true; hushCam.hushCam.stopViewfinder(); console.log("Navigator Hidden - Closing Viewfinder") } } } ]