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
Regular Contributor
Posts: 63
Registered: ‎08-05-2013
My Device: Blackberry-10 webworks
My Carrier: zcon

Headless Application Implementation in own project

Hi,

 

I want to implement headless app concept in my project.

 

The basic concept of my project is, I want to send data usage log,text message count,gps location,call logs to server.

After each 30 sec. will check whether maximum limit is crossed for any data. Once this limit is cross we will send all data to server in xml format. Till now this all functionality is present in one project. Now I want to devide it in two parts like UI and headless part.

 

But I am not able to understand how to make two parts of the application.

 

Which part  of the application I need to kept in headless part.

 

If I create two parts like all the screens are present in UI part and all bussiness logic in headless part then for each 30 sec how can I communicate between them.

 

 

 

Please correct me if I am wrong and offer some suggetions.

 

Retired
Posts: 571
Registered: ‎06-25-2010
My Device: Z10
My Carrier: Vodafone

Re: Headless Application Implementation in own project

The best way to communicate between the two parts is to use InvokeRequest from the invocation framework.

--------------------------------------------------------------------------------------------
Feel free to press the like button on the right side if you liked my attempts to help :-)
And please mark posts as solved if you think I found the solution or set you on its path. Thanks!
Follow me on Twitter: @mdwrim
BlackBerry Development Advisor
Posts: 249
Registered: ‎07-14-2008
My Device: Not Specified

Re: Headless Application Implementation in own project

Although I do not have full visibility to your usecase, I will try to recommend the best option here.

 

I dont think you need to communicate between the UI and the service every 30 seconds. You can have the UI to control some settings and whenever that changes you can invoke the headless part to refresh the settings..

 

The headless part would be solely responsible for collecting the data as well as sending the data to the server. Hence, I dont see a need for the headless and UI to communicate every 30 seconds in this case.

 

Re: communication channel between headless and UI, as Martin mentioned you can use the invocation framework. However, note that you can only invoke the headless from the UI and not the other way around. The other way to communicate is via local sockets OR you can share a file between the two.

 

Shadid

Regular Contributor
Posts: 63
Registered: ‎08-05-2013
My Device: Blackberry-10 webworks
My Carrier: zcon

Re: Headless Application Implementation in own project

Hi Shaque,

 

Thanks for your reply..
I have some doubts related to headless application. 

 

Basic structure of my project is like through the application we are sending current data usage, call logs, no of SMS to the server when any one of this exceeds the maximum limit which is previously set. So to check the maximum limit I am calling on function after 30 sec. First we have registration screen and then screens to show current send data usage n all..

 

So need of headless application in my project is we want to send data usage to server even if application is closed by user.

 

If I place UI part in one project and all business logic like sending data usage, checking registration in headless part, then how can I communicate between them...

e.g. If user want to register he will place user name and password then how to pass this values to headless application to call the web service and get the result?

Again according to result display a message to user. Blackberry provides invocation framework method. but how to use it for my concept?

 

Please help me to clear my doubts..

 

BlackBerry Development Advisor
Posts: 249
Registered: ‎07-14-2008
My Device: Not Specified

Re: Headless Application Implementation in own project

There are several ways to communicate between the UI and Headless process. 

 

Invocation Framework: This is the easiest but it only allows you to invoke headless from UI but you cant invoke the UI from headless.

 

QSettings: Whenever there is a change, your headless or the UI process can write them to QSettings whcih essentially writes the data to a file. The process that needs to know about this change can create a QFileSystemWatcher to watch for changes. Please see

HeadlessServiceUI

HeadlessService

 

Local Sockets: This is probably the best but it is not the easiest to implement. Your headless can open a server socket that your UI connects to. Once the connection is made, both can communicate in real time. Please see

XandOs

XandOsDroid

 

Hope this helps.

 

Shadid