Invoking application from background application | developer.brewmp.com Invoking application from background application | developer.brewmp.com

Developer

Invoking application from background application

Forums:

Hi all
I want to develop an application which have a phone service and a phone client.The phone service is running on the background and invoke the phone client application at a particular time.

I have developed the phone service by Handling event EVT_NOTIFY when phons's powers on by sending the application on background using ISHELL_StartBackgroundApplet(..).and start the client app using ISHELL_StartApplet(). But the problem is that how the background application invoke the client application at a particular time instead of phons power on.How I calculate the time in the background application and match that time to invoke the client application.

please light some focus on TBT issues as the service application always run on the background once the power on or brew initialize on the device.

also what can be the alternative solution for the above problem....

waiting for your replies...............

"But the problem is that how the background application invoke the client application at a particular time instead of phons power on.How I calculate the time in the background application and match that time to invoke the client application."
>>> At what point in time your background application should invoke the main client application?
Possibly I am unable to understand your requirement.

"But the problem is that how the background application invoke the client application at a particular time instead of phons power on.How I calculate the time in the background application and match that time to invoke the client application."
>>> At what point in time your background application should invoke the main client application?
Possibly I am unable to understand your requirement.

Hi, ruben
thanks for your reply..let me describe the problem more.
I want my background application invoke the client application at a particular time like every day 4 pm. Once the user uses the features of the client application, terminates the client application, the background app invoke it (client app) on next day 4 pm.So how I calculate the time in my background application(ie 4 pm),so that I invoke the client app at that time by using ISHELL_StartApplet().Now the approach is that the background application calculate the device time at every interval of time say 30 minutes and if it 4 pm (just a assumptions) then invoke client application by using ISHELL_StartApplet.But for the above requirment(client app should invoke at 4 pm everyday) the background app always runs on the device and calculating the time, so that it invoke the client app.
Note:when the power on in the device and brew initialized I send the background app to background by handling EVT_NOTIFY.
Am I thinking in a right way, or there is any alternative solution for that.
please also focus some light on TBT issues with the app as the background app always runs on the device.

Hi, ruben
thanks for your reply..let me describe the problem more.
I want my background application invoke the client application at a particular time like every day 4 pm. Once the user uses the features of the client application, terminates the client application, the background app invoke it (client app) on next day 4 pm.So how I calculate the time in my background application(ie 4 pm),so that I invoke the client app at that time by using ISHELL_StartApplet().Now the approach is that the background application calculate the device time at every interval of time say 30 minutes and if it 4 pm (just a assumptions) then invoke client application by using ISHELL_StartApplet.But for the above requirment(client app should invoke at 4 pm everyday) the background app always runs on the device and calculating the time, so that it invoke the client app.
Note:when the power on in the device and brew initialized I send the background app to background by handling EVT_NOTIFY.
Am I thinking in a right way, or there is any alternative solution for that.
please also focus some light on TBT issues with the app as the background app always runs on the device.

posted by Softeast wrote:
As per your problem description, I don't think that you need a background application. It seems that You just need a reminder application which can start itself at the particular date and time.
For this purpose; you can use ISHELL_SetAlarm() API; here, On expiration of certain time duration; your applet will be getting EVT_ALARM event. You can easily check the class_id of the active applet, and if active applet is not your applet then you can start your applet by calling ISHELL_StartApplet().
You can check the below post for sample code
http://brewforums.qualcomm.com/showthread.php?postid=61985

posted by Softeast wrote:
As per your problem description, I don't think that you need a background application. It seems that You just need a reminder application which can start itself at the particular date and time.
For this purpose; you can use ISHELL_SetAlarm() API; here, On expiration of certain time duration; your applet will be getting EVT_ALARM event. You can easily check the class_id of the active applet, and if active applet is not your applet then you can start your applet by calling ISHELL_StartApplet().
You can check the below post for sample code
http://brewforums.qualcomm.com/showthread.php?postid=61985

Hi,
I have checked the above thread regarding setting alarm, but my requirement is a little bit different ,I want when the client application terminates the device should be usable for other application or other functionality of the device, and at a particular time my client application should be invoke.
By using the ISHELL_SetAlram() the problem is that the application in which I set the alarm, should be run always in the foreground so that I can not use the device for other application or device functionality.I hope now you can understand the problem more. please reply a solution for that.
A little more help appreciated....... .........

Hi,
I have checked the above thread regarding setting alarm, but my requirement is a little bit different ,I want when the client application terminates the device should be usable for other application or other functionality of the device, and at a particular time my client application should be invoke.
By using the ISHELL_SetAlram() the problem is that the application in which I set the alarm, should be run always in the foreground so that I can not use the device for other application or device functionality.I hope now you can understand the problem more. please reply a solution for that.
A little more help appreciated....... .........

You completely misunderstood SetAlaram please read API document...
Quote:
This method allows the caller to set a long-term alarm
for an applet. When the alarm expires, the applet will be loaded and
passed an EVT_ALARM event with the specified 16-bit nUserCode as the
user parameter.
If the applet is not active at the time of the alarm, it will be loaded
but will not be sent an EVT_APP_START event. If the applet wishes to
be activated, it must call ISHELL_StartApplet.
Do the following Steps:
1. Register for an ISHELL Notification and hande this only for the first time that the app install on the Handset...
2. In the EVT_NOTIFY event Get the current time and calculate how much time left to start the app than make a call to set Alaram API with that time.
Once you return TRUE to this Event your app will be unloaded from memory.
3.Once the Alaram expires in the BREW system, Then the registered app will be loaded on the heap and the app will recieve EVT_ALARAM event.
4. In this Event check the current running applet if any, if current running applet is not your applet then call ISHELL_StartApplet.
if Your remaining time is two large to fit in API call for set Alaram than divide the into some big intervals and recall the api again until you get the EVT_ALARAM at exact time 4AM/PM on that day.

You completely misunderstood SetAlaram please read API document...
Quote:
This method allows the caller to set a long-term alarm
for an applet. When the alarm expires, the applet will be loaded and
passed an EVT_ALARM event with the specified 16-bit nUserCode as the
user parameter.
If the applet is not active at the time of the alarm, it will be loaded
but will not be sent an EVT_APP_START event. If the applet wishes to
be activated, it must call ISHELL_StartApplet.
Do the following Steps:
1. Register for an ISHELL Notification and hande this only for the first time that the app install on the Handset...
2. In the EVT_NOTIFY event Get the current time and calculate how much time left to start the app than make a call to set Alaram API with that time.
Once you return TRUE to this Event your app will be unloaded from memory.
3.Once the Alaram expires in the BREW system, Then the registered app will be loaded on the heap and the app will recieve EVT_ALARAM event.
4. In this Event check the current running applet if any, if current running applet is not your applet then call ISHELL_StartApplet.
if Your remaining time is two large to fit in API call for set Alaram than divide the into some big intervals and recall the api again until you get the EVT_ALARAM at exact time 4AM/PM on that day.

Hi,
your post is greatly helpful for me, now I am able to understand ISHELL_SetAlarm(), but still there is a problem, when the client application terminates(by user), the back application(in which I use the ISHELL_SetAlarm(..)) also terminates(also you tell me whenever it return true its unloaded from heap that's why so). So next time the client application not executed because there is no any back application who invoke it.
post some guidelines how to solve the problem....
help appreciated...

Hi,
your post is greatly helpful for me, now I am able to understand ISHELL_SetAlarm(), but still there is a problem, when the client application terminates(by user), the back application(in which I use the ISHELL_SetAlarm(..)) also terminates(also you tell me whenever it return true its unloaded from heap that's why so). So next time the client application not executed because there is no any back application who invoke it.
post some guidelines how to solve the problem....
help appreciated...

The problem is your back ground application.
Use only single application that will slove your problem. Why you are using a background application for setting EVT_ALARM???
In your client application, set the alarm event in EVT_APP_STOP. so that it will make sure that you client app will invoke again once the alaram is expired.

The problem is your back ground application.
Use only single application that will slove your problem. Why you are using a background application for setting EVT_ALARM???
In your client application, set the alarm event in EVT_APP_STOP. so that it will make sure that you client app will invoke again once the alaram is expired.

Hi, Brewin
thanks for your replies....
Brewin wrote:
Use only single application that will slove your problem. Why you are using a background application for setting EVT_ALARM???
Now the problem get solved. :cool:

Hi, Brewin
thanks for your replies....
Brewin wrote:
Use only single application that will slove your problem. Why you are using a background application for setting EVT_ALARM???
Now the problem get solved. :cool: