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. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
Contributor
johnny1941
Posts: 36
Registered: ‎09-21-2011
My Carrier: none

Unable to delete field on top of RichMapField

hi,

 

In my app I have a RichMapField overlayed by a LabelField. I'm trying to delete the LabelField as soon as coordinates have been acquired by the GPS. The problem is I can change the text of the label, but not delete it. What am I doing wrong?

 

My code is below:

map = MapFactory.getInstance().generateRichMapField();
final LabelField locationNotAcquiredLabel = new LabelField("Acquiring location...");        
map.add(locationNotAcquiredLabel, 150, 150);             
Timer timer = new Timer();
final long start = System.currentTimeMillis();
timer.schedule(new TimerTask() {			
    public void run() {
        Location location = LocationListenerImpl.getInstance().getLastLocation();
        if (location != null) {
	long end = System.currentTimeMillis();
	String elapsed = String.valueOf((end - start) / 1000);						          map.getAction().setCentreAndZoom(new MapPoint(location.getQualifiedCoordinates()), 10);								
					locationNotAcquiredLabel.setText("Elapsed: " + elapsed + " seconds"); // Works
        map.delete(locationNotAcquiredLabel); // Doesn't work
        map.getMapField().update();
	this.cancel();
	}
    }
}, 0, 1000);
        
add(map);

 

Please use plain text.
Administrator
MSohm
Posts: 12,957
Registered: ‎07-09-2008
My Carrier: Bell

Re: Unable to delete field on top of RichMapField

Which BlackBerry Smartphone model and BlackBerry handheld software version are you testing on?  You can find this under Options, About on the BlackBerry Smartphone.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Found a bug? Report it using the Issue Tracker
Please use plain text.
Contributor
johnny1941
Posts: 36
Registered: ‎09-21-2011
My Carrier: none

Re: Unable to delete field on top of RichMapField

It's the BB 9780 running OS 6.0 bundle 3106 (v6.0.0.723, Platform 6.6.0.248)

Please use plain text.
Developer
rabiray
Posts: 141
Registered: ‎07-13-2011
My Carrier: Vodafone

Re: Unable to delete field on top of RichMapField

There is a very good article by Peter on background process...I hope this will help you.

http://supportforums.blackberry.com/t5/Java-Development/Sample-quot-Please-Wait-quot-screen-part-1/t...

Please use plain text.
Administrator
MSohm
Posts: 12,957
Registered: ‎07-09-2008
My Carrier: Bell

Re: Unable to delete field on top of RichMapField

This is caused by trying to update a screen from outside of the main event thread.  This article explains it (Peter's does cover it as well, but he has a lot more info in there too).

 

 

Update a screen on the Main Event Thread

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Found a bug? Report it using the Issue Tracker
Please use plain text.