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
Super Contributor
Achin
Posts: 425
Registered: ‎01-02-2013
My Device: BOLD 9900
My Carrier: sdvsdvsd
Accepted Solution

how to use RealtimeClockListener

i hv used this code to get the time on every minute works fine it give me time on evry minute but if i close the app then it's not working,i mean after closing the app how would i run that code in background.to get the time

 

public class BackgroundApp extends UiApplication implements RealtimeClockListener
{
/**
* Entry point for application
* @param args Command line arguments (not used)
*/
public static BackgroundApp theApp=null;
public static void main(String[] args)
{
// Create a new instance of the application and make the currently
// running thread the application's event dispatch thread.
theApp = new BackgroundApp();
theApp.enterEventDispatcher();
}


/**
* Creates a new MyApp object
*/
public BackgroundApp()
{
// Push a screen onto the UI stack for rendering.

addRealtimeClockListener(this);
}


public void clockUpdated() {
int hour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
int minute = Calendar.getInstance().get(Calendar.MINUTE);
System.out.println(""+hour+":"+minute);



}
}

Please use plain text.
Developer
simon_hain
Posts: 15,947
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: how to use RealtimeClockListener

you did not implement the background part correctly, re-read the link about alternate entry points we gave you.
if you define the entry point as autostart/system module you cannot shut it down as a user.
----------------------------------------------------------
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
Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: how to use RealtimeClockListener

I suggest you think about implementing Application rather than UiApplication for your background processing too. 

 

Put "Background Application" in the Search for more information. 

Please use plain text.
Super Contributor
Achin
Posts: 425
Registered: ‎01-02-2013
My Device: BOLD 9900
My Carrier: sdvsdvsd

Re: how to use RealtimeClockListener

one more thing i have to ask ,when i used the following

 

public class HighResolutionScreen extends MainScreen implements RealtimeClockListener{

public void clockUpdated() {
// TODO Auto-generated method stub

try {
int hour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
int minute = Calendar.getInstance().get(Calendar.MINUTE);
System.out.println(""+hour+":"+minute);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

 

}

and i consloe after every minute it show me following

VM:smileytongue:ISVt=0,h=2161,id=9a15b00dba73bc69
[0.0] VM:IGCSc=4
[0.0] VM:smileytongue:ISVt=0,h=2161,id=9a15b00dba73bc69
[0.0] VM:IGCSc=4
[0.0] VM:smileytongue:ISVt=0,h=2161,id=9a15b00dba73bc69

 

Please use plain text.
Super Contributor
Achin
Posts: 425
Registered: ‎01-02-2013
My Device: BOLD 9900
My Carrier: sdvsdvsd

Re: how to use RealtimeClockListener

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

Re: how to use RealtimeClockListener

When you debug your code, does your clockUpdated() method get called?  If not (and I suspect it does not), then review the API to understand why not. 

 

http://www.catb.org/esr/faqs/smart-questions.html#urgent

Please use plain text.
Super Contributor
Achin
Posts: 425
Registered: ‎01-02-2013
My Device: BOLD 9900
My Carrier: sdvsdvsd

Re: how to use RealtimeClockListener

yes, my clockUpdated() method did not called. i dont know why.can u help me
Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: how to use RealtimeClockListener

You need:

<your Application>.addRealtimeClockListener(<your RealtimeClockListener>);

 

Next time, please debug this and tell us that the method was not being called in the first Post.

Please use plain text.