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
Royster86
Posts: 102
Registered: ‎03-13-2012
My Device: 9360, P'9981, Z10

Unable to get headless apps working

Hi all,

 

I've just been granted the long running app permission, however I'm not having much luck with the examples.

 

I firstly tried to edit my existing projects into two parts by following https://developer.blackberry.com/native/documentation/core/headless_apps_create_headless_app.html#bu...

 

- didn't have any luck there, so I instead started with two clean projects and worked through the steps. However, I get the same result.

 

The background process is never invoked. I set a breakpoint on the:

 

qDebug() << "Hello Headless App" << endl;

 line, but it is never reached. My understanding is that as I have the system started action, that this should fire off as soon as the app is debugged.

 

Im using the latest 10.2 SDK and the latest device software (dev alpha c).

 

I also looked in the device log to see if there was anything wrong, but I don't see any errors - I also do not see the background app running in the process stack in the debug view.

 

I feel as though I'm missing something obvious (this is my first time using the invokation framework).

 

I've built the background project in debug mode, and then built and debugged the main ui app.

 

My entire bar descriptor is below - I have also removed the assets folder and the bar descriptor from the BackgroundApp project.

 

<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!--
  
   Copyright (c) 2011, 2012, 2013 Research In Motion Limited.
  
   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at
  
   http://www.apache.org/licenses/LICENSE-2.0
  
   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
  
-->
<qnx xmlns="http://www.qnx.com/schemas/application/1.0">

<!-- BlackBerry 10 application descriptor file.

    Specifies parameters for identifying, installing, and launching native applications on BlackBerry 10.

-->

    <!-- A universally unique application identifier. Must be unique across all BlackBerry 10 applications.
         Using a reverse DNS-style name as the id is recommended. (Eg. com.example.ExampleApplication.) Required. -->
    <id>com.example.ForegroundApp</id>

    <!-- The name that is displayed in the BlackBerry 10 application installer. 
         May have multiple values for each language. See samples or xsd schema file. Optional. -->
    <name>ForegroundApp</name>
    
    <!-- A string value of the format <0-999>.<0-999>.<0-999> that represents application version which can be used to check for application upgrade. 
         Values can also be 1-part or 2-part. It is not necessary to have a 3-part value.
         An updated version of application must have a versionNumber value higher than the previous version. Required. -->
    <versionNumber>1.0.0</versionNumber>

    <!-- Fourth digit segment of the package version. First three segments are taken from the 
         <versionNumber> element.  Must be an integer from 0 to 2^16-1 -->
    <buildId>1</buildId>
                 
    <!-- A string value (such as "v1", "2.5", or "Alpha 1") that represents the version of the application, as it should be shown to users. Optional. -->
    <!-- <versionLabel></versionLabel> -->

    <!-- Description, displayed in the BlackBerry 10 application installer.
         May have multiple values for each language. See samples or xsd schema file. Optional. -->
    <description>The ForegroundApp application</description>

    <!-- Copyright information. Optional. -->
    <!-- <copyright></copyright> -->

    <!--  Name of author which is used for signing. Must match the developer name of your development certificate. -->
    <author>Example Inc.</author>
    <configuration name="Device-Debug">
       <platformArchitecture>armle-v7</platformArchitecture>
       <asset path="arm/o.le-v7-g/ForegroundApp" entry="true" type="Qnx/Elf">ForegroundApp</asset>
       <asset entryPointId="BackgroundApp" path="../BackgroundApp/arm/BackgroundApp" type="Qnx/Elf">BackgroundApp</asset>
    </configuration>
    <configuration name="Device-Release">
       <entryPointType>Qnx/Cascades</entryPointType>
       <platformArchitecture>armle-v7</platformArchitecture>
       <asset path="arm/o.le-v7/ForegroundApp.so" entry="true" type="Qnx/Elf">ForegroundApp.so</asset>
    </configuration>
    <configuration name="Device-Profile">
       <platformArchitecture>armle-v7</platformArchitecture>
       <asset path="arm-p/o.le-v7-g/ForegroundApp" entry="true" type="Qnx/Elf">ForegroundApp</asset>
    </configuration>
    <configuration name="Simulator-Debug">
       <platformArchitecture>x86</platformArchitecture>
       <asset path="x86/o-g/ForegroundApp" entry="true" type="Qnx/Elf">ForegroundApp</asset>
    </configuration>
    
    <!--  Unique author ID assigned by signing authority. Required if using debug tokens. -->
    <!-- <authorId>...</authorId> -->
    
    <entryPoint id="ForegroundApp">
    	<name>ForegroundApp</name>
	</entryPoint>
	<entryPoint id="BackgroundApp">
	    <name>BackgroundApp</name>
	</entryPoint>
   
    <initialWindow>
        <autoOrients>true</autoOrients>
        <systemChrome>none</systemChrome>
        <transparent>false</transparent>
    </initialWindow>
    
    <!--  The icon for the application, which should be 114x114. -->
    <icon>
        <image>icon.png</image>
    </icon>

    <asset path="icon.png">icon.png</asset>
    <asset path="assets">assets</asset>
    
    <!-- Locale support -->
    <asset path="translations" dest="qm">
        <include name="*.qm"/>
    </asset>
    
    <!-- Request permission to execute native code.  Required for native applications. -->
    <permission system="true">run_native</permission>
    <permission system="true">_sys_run_headless</permission>
    <permission system="true">_sys_headless_nostop</permission>
    <env var="LD_LIBRARY_PATH" value="app/native/lib:/usr/lib/qt4/lib"/>
    
    <invoke-target id="com.example.ForegroundApp">
	    <invoke-target-type>application</invoke-target-type>
	    <invoke-target-name>ForegroundApp</invoke-target-name>
	    <entry-point-id>ForegroundApp</entry-point-id>
    </invoke-target>
    
    <invoke-target id="com.example.BackgroundApp">
	    <invoke-target-type>application.headless</invoke-target-type>
	    <invoke-target-name>BackgroundApp</invoke-target-name>
	    <entry-point-id>BackgroundApp</entry-point-id>
	    <filter>
	        <action>bb.action.system.STARTED</action>
	        <mime-type>application/vnd.blackberry.system.event.STARTED</mime-type>
	        <property var="uris" value="data&colon;//local"/>
	    </filter>
	</invoke-target>
	

</qnx>

 

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

Re: Unable to get headless apps working

Hi,

Does this sample app work on your device? Note that you need to import both to your workspace and build.

 

headlesservice

headlesserviceui

 

Shadid

Developer
Royster86
Posts: 102
Registered: ‎03-13-2012
My Device: 9360, P'9981, Z10

Re: Unable to get headless apps working

Hi Shadid,

This works - however I am not able to debug the background process - is this a known limitation?

I seem to get an error when I set a breakpoint: No source file named applicationheadless.cpp.
New Developer
Shiryu
Posts: 13
Registered: ‎09-26-2013
My Device: z10

Re: Unable to get headless apps working

Hi Shadid.

 

It works only device-debug BUT it doesn't work with device-release :smileysad:

 

I also removed "<permission system="true">_sys_headless_nostop</permission>" for testing short running app BUT still doesn't work as well.

 

 

 

Developer
Royster86
Posts: 102
Registered: ‎03-13-2012
My Device: 9360, P'9981, Z10

Re: Unable to get headless apps working

I've worked out why my app wasn't actually working in the first place - it was down to the entryPointId line in the launch config for the ForegroundApp being missing (e.g. notice that in my bar descriptor I have:
entryPointId="BackgroundApp" - but I do not have entryPointId="ForegroundApp". Maybe the "Creating a headless app" page needs to be updated?

I added this and was able to see output in the console from the background process.

However, the ability to debug the background process is still not working for me.

Shiryu, I haven't had chance to test this in release yet - I will test today and come back to you.
New Developer
Shiryu
Posts: 13
Registered: ‎09-26-2013
My Device: z10

Re: Unable to get headless apps working

Hi Royster86,

 

I have tested with headless app and found that auto start headless app will work only "device-debug" with the latest firmware version 10.2.0.1793.

 

And thank you for your help to test in release version :smileyhappy:

 

 

 

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

Re: Unable to get headless apps working

I can confirm the issue with release mode. Good news is, we have a solution that requires a small edit in your bar-descriptor. Just cleaning it up and making sure that I am doing it in the best way possible before I share here. Please stay tuned.
Developer
Royster86
Posts: 102
Registered: ‎03-13-2012
My Device: 9360, P'9981, Z10

Re: Unable to get headless apps working

OK, now I really am confused.

 

Since yesterday, I'm now trying to re-run the projects I created, and now none of them working.

 

I even re-downloaded the headlesserviceui projects and this isn't working, even in debug mode.

 

Yesterday when I ran the code, I got the flashing blue LED (run by the background process) and in the app GUI there was a green box, with a flash counter and a remaining count, which would decrease until the "Restart" button was pressed.

 

Now I get a red box with "N/A" written in it, Flashcount: 0 and RemainingCount: -1.

 

Hitting the reset button sets the RemainingCount to 0. There is now no blue LED.

 

I've tried putting different firmware on the handset, but even after reverting to the same firmware I was on yesterday, the same thing happens. I also checked my debug token and it seems correct.

 

Any ideas?

Developer
Royster86
Posts: 102
Registered: ‎03-13-2012
My Device: 9360, P'9981, Z10

Re: Unable to get headless apps working

OK, tried another device - worked fine - my Dev Alpha C for some reason refuses to run background processes? All background permissions are OK and the debug token is fine.

I made no alterations to the code in the projects.
New Developer
Shiryu
Posts: 13
Registered: ‎09-26-2013
My Device: z10

Re: Unable to get headless apps working

Hi Shadid,

 

Hopefully, you can fix it soon :smileywink: