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

Java Development

Reply
Regular Contributor
mihaizzav
Posts: 55
Registered: ‎08-26-2010
My Device: 8520
Accepted Solution

Autostart application not starting on reset

Hello ,

I have an application which contains 2 cod files: the main application cod, and a library cod (for json parsing & storing images). The main cod starts imediately as the phone boots. After installing these cod files , the application runs perfectly. After I remove the battery and reinsert it and reboot the phone , the application starts but cannot access some image files stored in the library cod and crashes. This thing does not happen in the simulator.

 

Is there any way to fix this? I even set the main cod dependent of the library cod and it still crashed after reset.

I updated the main jad with data from the library jad using UpdateJad.exe and loaded the jad on the phone with javaloader.

 

Can anyone help me on this ? I think it has to do with the fact that the main cod gets loaded into memory before the library cod, and because it needs to read some images from the library cod, it cannot find the library module and crashes.

Please use plain text.
Developer
ekke
Posts: 1,440
Registered: ‎04-08-2010
My Device: Z10 (red Limited Edition), Q10, Z30
My Carrier: Telekom.de, O2, Vodafone

Re: Autostart application not starting on reset

try adding a SystemListener and wait until PowerUp() before doing your work

perhaps you try to get the images before all is ready

-------------------------------------------------------------------------------
ekke (independent software architect, rosenheim, germany)

BlackBerry Elite Developer
International Development Mobile Apps BlackBerry 10 Cascades
Cascades - Workshops / Trainings / Bootcamps

Open Source Enthusiast
blog: http://ekkes-corner.org videos: http://www.youtube.com/user/ekkescorner
bb10-development: http://appbus.org Twitter: @ekkescorner
Please use plain text.
Developer
gercoder
Posts: 46
Registered: ‎06-11-2009
My Device: Bold 2 - Pearl 8120

Re: Autostart application not starting on reset

Have you tried to turn on Autorun on startup on Descriptor.xml for both app and library?

If your issue is resolved, please mark this thread as solved. Click "Accept as solution" on the post that contains the answer to your question.
Please use plain text.
Regular Contributor
mihaizzav
Posts: 55
Registered: ‎08-26-2010
My Device: 8520

Re: Autostart application not starting on reset

My main cod has a SystemListener that waits for the phone to boot , after that it calls the method powerUp where i begin to load the images.  I set both the main cod and the library as autostart but it didn't work. I'll try to implement the image loading in the libMain(String[] args) method.

 

Thanks for the reply.

Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: Autostart application not starting on reset

I agree with the previous answers. 

 

I am suspicious of some coding bug.  Your Library cod does not, it appears, wait for the Phone to start up.  and you say "cannot access some image files stored in the library cod".  So I would very closely follow the processing that should take place at start-up for both your Library and the main cod 

 

I find this sort of start-up problems difficult to isolate because of the problem debugging them at start-up time on the device.  So I would make sure you start up processing in both writes log entries to the Event Log and/or puts a copy in some rolling internal array that you can access, so that you can review the start up sequence once the device is up.  I think if you do add this logging, you will find this problem. 

 

Two more things:

 

A) Can we have a little more detail on what you actually see and what actually causes the the problems.  In the first post you said "I think it has to do...".  Why do you think this and how exactly does your application 'fail' - Null Pointer Exception, or what. 

 

B) In your last post you said:

"I'll try to implement the image loading in the libMain(String[] args) method"

I would say that this will not work, unless your libMain also starts an Application, and this Application has a System Listener that waits for the device to become ready. 

 

Please use plain text.
Regular Contributor
mihaizzav
Posts: 55
Registered: ‎08-26-2010
My Device: 8520

Re: Autostart application not starting on reset

Got the event log after hard reset. I get a ControlledAccessException when i load the persistent object. I know why this happens. It has nothing to do with loading images.

 

I have a question about persisting protected data. Do I always have to call setContents() before commit() for a PersistentObject ?

 

My application persists data on most of the operations, even on the powerDown event.

Please use plain text.
Regular Contributor
mihaizzav
Posts: 55
Registered: ‎08-26-2010
My Device: 8520

Re: Autostart application not starting on reset

Thx for the event log ideea. It would have been really hard to debug.

Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: Autostart application not starting on reset

I get ControlledAccessException sometimes, the first reset after an install.  It generally works if I reset again.  Can you try that?

Please use plain text.
Regular Contributor
mihaizzav
Posts: 55
Registered: ‎08-26-2010
My Device: 8520

Re: Autostart application not starting on reset

After 3 resets I still get the ControlledAccessException. I can avoid this by not protecting my persistent data.

 

The exception is thrown when I call the method getContents(codeSigningKey) on the persistentObject.

 

code executed at startup:

 

PersistentObject storage = PersistentStore.getPersistentObject(storageID);
tasks = (TaskHashtable) storage.getContents(codeSigningKey);
if (tasks == null) {
	tasks = new TaskHashtable();
	storage.setContents(new ControlledAccess(tasks,
			codeSigningKey));
	storage.commit();
}

 

 

every time after I add something to my hashtable or I turn off the phone I execute this code:

 

synchronized (storage) {
	storage.commit();
}

 

Maybe I'm not persisting data correctly.

 

 

Well tks for posting.

Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: Autostart application not starting on reset

I don't actually use ContentProtection, so this is all new to me.  But I wonder if Content Protection ties storage to an application, and you have two applications, the Library and whatever it is running, plus the main cod.

 

Just a random thought, probably not very helpful.

Please use plain text.