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
maminde
Posts: 73
Registered: ‎05-03-2011
My Device: 9550
My Carrier: verison
Accepted Solution

how to implement service thread as know headless app?

I want to implement some service app such as GPS log, SMS firewall. Just want expert to give some guide about how to design headless app and how to interact headless thread with UI front?

Author of pairs and Gradient
Please use plain text.
Developer
AdrianQuartx
Posts: 105
Registered: ‎09-06-2013
My Device: Z10

Re: how to implement service thread as know headless app?

There is documentation for this: Here,

Sample Apps: Push Collector and Xandroid UI portion/Xandroid Headless Portion

 

Personally I couldnt get the Push Collector working but the Xandroid works according to others.

I tried making a UI + logic seperated app and tried invoking the logic part on system started but couldnt get it to work too.

 

If your headless app needs long running and is non triggered u need to submit a form at https://developer.blackberry.com/jam/headless/

 

I sure hope the internal devs release a simple start on system start hello world sort of example, both sample apps are too complicated and try to squeeze too many different features together

Please use plain text.
Developer
maminde
Posts: 73
Registered: ‎05-03-2011
My Device: 9550
My Carrier: verison

Re: how to implement service thread as know headless app?

thanks for quick response, I will read through the stuff. If I get some work, I will exchange experience with you.

Author of pairs and Gradient
Please use plain text.
Developer
xnike
Posts: 59
Registered: ‎11-04-2011
My Device: PlayBook, DAC, STL100-1, STL100-2
My Carrier: MTS RUS

Re: how to implement service thread as know headless app?

It's a strange idea to use a predefined TCP port in a headless service. What if another applications will use the same port all the time? Applications will work incorrectly.

Please use plain text.
Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: how to implement service thread as know headless app?

It's suboptimal, but it's not all that unusual to use TCP or even UDP for IPC like that.

One approach you can use is NOT to hardcode a predefined port number. Rather, the side that will be opening the socket as a server/listener opens it with "port 0", which lets the OS assign an unused port. Then it writes that port number into a file, which is used by the other (client) side of the connection to know where to connect.

Since this avoids collisions, it generally will work without an issue. If you protect it with some token security (like a shared secret that can also be written to that private file) then it's also fairly immune to attempts to interfere with it from other (malicious) apps.

It's not unprecedented or unworkable.

Other options may be Unix sockets (effectively a different namespace) and possibly even pipes. Anyone looked into whether either or both of those are options for us here?

Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Please use plain text.
Developer
maminde
Posts: 73
Registered: ‎05-03-2011
My Device: 9550
My Carrier: verison

Re: how to implement service thread as know headless app?

that's like street number of address, if not, how could poster find you? server and client must have negotiate with some predefination.

Author of pairs and Gradient
Please use plain text.
Developer
xnike
Posts: 59
Registered: ‎11-04-2011
My Device: PlayBook, DAC, STL100-1, STL100-2
My Carrier: MTS RUS

Re: how to implement service thread as know headless app?

I'd rather sent a server port  from the UI part in the invocation request )

 

As I see _sys_run_headless shows that application can be possibly run all the time, but system can stop it eventually, restart and so on. Is it right?

 

"Long-running headless applications require the _sys_headless_nostop system permission to run at all times." - why should I ask BBRY for approval? Will this give me garanties that my headless part will work all the time, even on low memory due to another applications? 

Please use plain text.
Developer
xnike
Posts: 59
Registered: ‎11-04-2011
My Device: PlayBook, DAC, STL100-1, STL100-2
My Carrier: MTS RUS

Re: how to implement service thread as know headless app?

I am facing to problem of "failed to bind to port" at work too often due to some one decided to use predefined port thinking that "server and client must have negotiate with some predefination".

 

Would you like to get a negative reviews of the program due to someone use the same tcp port? BBRY should not provide such a REALLY BAD example of the IPC.

Please use plain text.