×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Registered User
    Join Date
    Mar 2008
    Posts
    26

    Exclamation Register callback to execute when the application goes to background and foreground

    If tried using the following code but my callback function is never called.

    program = HILDON_PROGRAM(hildon_program_get_instance());
    g_signal_connect(G_OBJECT(program), "notify::is-topmost", G_CALLBACK(topmost_status_change), NULL);


    After adding the following code in callback function from "osso_hw_set_event_cb" I've noticed that the "is-topmost" value is never changed, even when the app is on background.

    g_object_get(G_OBJECT(program),"is-topmost",&flag,NULL);
    qWarning() <<"##### Minimize application inactivity event!" << flag ;


    So I suspect that hildon_program_get_instance() might not be the same QApplication that I'm executing. Any suggestions?

  2. #2
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: Register callback to execute when the application goes to background and foregrou

    You need to register your windows to the program with hildon_program_add_window.

  3. #3
    Registered User
    Join Date
    Mar 2008
    Posts
    26

    Re: Register callback to execute when the application goes to background and foregrou

    Im creating a window using "hildon_window_new ()". Is that correct?
    I don't think so, because when a invoke "hildon_banner(window,msg,..)" the banner it's being shown even with app on bg;
    Is there a way to create a HildonWindow from QApplication?



    <---------code ------------ >
    ...
    program = HILDON_PROGRAM(hildon_program_get_instance());
    window = HILDON_WINDOW (hildon_window_new ());

    hildon_program_add_window (program, window);
    g_signal_connect(G_OBJECT(program), "notify::is-topmost", G_CALLBACK(topmost_status_change), NULL);

    /* Initialize GLoopMain object*/
    //g_type_init();
    loop = g_main_loop_new(NULL, FALSE);

    /* Initialize Liblocation object*/
    control = location_gpsd_control_get_default();
    device = g_object_new(LOCATION_TYPE_GPS_DEVICE, NULL);

    /* Connect Signals/Slots */
    g_object_set(G_OBJECT(control),
    "preferred-method", LOCATION_METHOD_USER_SELECTED,
    "preferred-interval", LOCATION_INTERVAL_60S,
    NULL);

    g_signal_connect(device, "changed", G_CALLBACK(on_changed), control);
    g_signal_connect(device, "connected", G_CALLBACK(on_connected), NULL);
    g_signal_connect(device, "disconnected", G_CALLBACK(on_disconnected), NULL);


    g_main_loop_run(loop);
    ....
    <---------------------------->
    Last edited by romulovitor; 2010-01-20 at 23:46.

  4. #4
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: Register callback to execute when the application goes to background and foregrou

    Now it looks more like Gtk for Maemo.

  5. #5
    Registered User
    Join Date
    Mar 2008
    Posts
    26

    Re: Register callback to execute when the application goes to background and foregrou

    Well, If U know another way to get callback when the application goes to background and foreground, either by QDBus or any other QApplication method I would appreciate ;-)


    On qt 4.5 I'm using multiple QMainWindow to stack them, and I couldn't find and QEvent that would do the trick for me since the same event is dispatched for window1 when both the window1 go to background and window2 is shown;

    QMainWindow *window1 = new QMainWindow;
    QMainWindow *window = new QMainWindow(Window1);




    Thank you for the quick reply.
    Last edited by romulovitor; 2010-01-21 at 03:18.

  6. #6
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: Register callback to execute when the application goes to background and foregrou

    We have an article in wiki how to do that with Qt:
    http://wiki.forum.nokia.com/index.ph...tus_in_Maemo_5

  7. #7
    Registered User
    Join Date
    Mar 2008
    Posts
    26

    Re: Register callback to execute when the application goes to background and foregrou

    Perfect!! That does the job wonderfully!!

    Thank you very much!!!

Similar Threads

  1. Can't capture keypress in background application
    By Jick in forum Symbian User Interface
    Replies: 4
    Last Post: 2010-04-07, 05:39
  2. Replies: 0
    Last Post: 2008-04-24, 12:33
  3. Bringing Background application to foreground
    By Varadarajanm in forum Symbian
    Replies: 1
    Last Post: 2007-02-21, 02:43
  4. Replies: 7
    Last Post: 2005-09-05, 14:36
  5. Moving application in background and foreground
    By lilesh in forum Symbian User Interface
    Replies: 5
    Last Post: 2005-06-16, 10:00

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •