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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Developer
Posts: 191
Registered: ‎04-02-2013
My Device: BlackBerry Bold 9900
My Carrier: developer

Application crashes while using the Custom Class

Hi 

I am created a  custom class extending the Thread class. And i am using that class in my constructor as:

 

public MyApp()

{

//AnimatedGifField

 

CustomThread thread = new CustomThread();

thread.start();

}

 

class CustomThread extends Thread

{

public void run()

{

//Openng the browser field here.While the document gets loaded.Deleting the animatedGifField and added the document.

 

synchronized (UiApplication.getEventLock())
{
manager2.delete(gifManager);
VerticalFieldManager vfm = new VerticalFieldManager();
vfm.add(Catalogue.browserField);
manager2.add(vfm);
}

 

 

super.run();

}

}

 

But after sometime when the device goes into sleep state the application gets closed. What is the thing that causes the application crash??

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Application crashes while using the Custom Class

[ Edited ]

Can you explain in words, what this code is intended to do and why you think it is needed.  The code looks, well, weird, and I don't want to spend time debugging a bit of code that in fact is not needed or not doing the right job. 

Developer
Posts: 191
Registered: ‎04-02-2013
My Device: BlackBerry Bold 9900
My Carrier: developer

Re: Application crashes while using the Custom Class

Sir

I have to load the webpage from the server and display it in the browser implemented in the application.

Till the page is loading, i have added an animated gif image and when the page is loaded the manager in which the image is added is deleted and the browserfield is added to its place.

 

May i know why the code is wierd???

Developer
Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Application crashes while using the Custom Class

it makes no sense to use a thread for that.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Application crashes while using the Custom Class

I understand what the code is trying to do since you said that in the comments.  I was more concerned about the actions your code was taking to achieve this.  What is the processing involved - what does starting the Thread achieve, how do you know that the BrowserField has been loaded?  I see nothing in the code that actually indicates that it will achieve what you want.  So perhaps you could explain how your code was going to work? 

 

In fact I think the code is unlikely to be using the recommended approach to doing this.  I suggest searching before you try things that are new to you, you might for example have found this:

 

http://supportforums.blackberry.com/t5/Java-Development/After-loading-the-web-page-I-want-to-display...

 

One final thing.  Since I am not sure that you understand the full implications of using

"synchronized (UiApplication.getEventLock()) {

// Code to run on the Event Thread

}"

I recommend that instead you use

"UiApplication.getUiApplication().invokeLater(new Runnable() {

public void run() {

// Code to run on the Event Thread

}

});"