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?
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.
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);
....
<---------------------------->
Re: Register callback to execute when the application goes to background and foregrou
Now it looks more like Gtk for Maemo.
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.
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:
[url]http://wiki.forum.nokia.com/index.php/How_to_monitor_application_topmost_status_in_Maemo_5[/url]
Re: Register callback to execute when the application goes to background and foregrou
Perfect!! That does the job wonderfully!!:):D:D
Thank you very much!!!