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
Developer
weaselgrater
Posts: 87
Registered: ‎08-25-2009
Accepted Solution

Adding locationPicker throws IllegalStateException

 

Thread [Ritis_Maps(180)id=253124608] (Suspended (exception IllegalStateException))    
    LocationPicker(Screen).setManager(Manager, int) line: 6219    
    VerticalFieldManager(Manager).insertInternal(Field, int) line: 2203    
    VerticalFieldManager(Manager).add(Field) line: 545    
    TitleStatusManager.add(Field) line: 609    
    AdvancedIncidentListOptions(Screen).add(Field) line: 288    
    AdvancedIncidentListOptions.addComponents() line: 147    
    AdvancedIncidentListOptions.<init>() line: 93    

 

 

I have a MainScreen in which I am adding my LocationPicker. I call add(locationPicker);

 

I call this method before, to set up the locationPicker.

 

 

private void readyLocationPicker(){
	Vector locationpick = new Vector();
	

	locationpick.addElement(GPSLocationPicker.getInstance());

	
	Landmark[] landmarks = new Landmark[1];
	landmarks[0] = new Landmark("DC Beltway", "Center of 495 Beltway", new QualifiedCoordinates(LATITUDE_CENTER_OF_DC_BELTWAY, LONGITUDE_CENTER_OF_DC_BELTWAY, Float.NaN, Float.NaN, Float.NaN), null);
	final SuggestedLocationPicker slp = SuggestedLocationPicker.getInstance("Suggested Locations...", landmarks);
	locationpick.addElement(slp);
	
	locationpick.addElement(EnterLocationPicker.getInstance(true));
	locationpick.addElement(MapsLocationPicker.getInstance());
	locationpick.addElement(RecentLocationPicker.getInstance());
	locationpick.addElement(ContactsLocationPicker.getInstance(true));

	LocationPicker.Picker[] locationPickersArray = new LocationPicker.Picker[locationpick.size()];
	locationpick.copyInto(locationPickersArray);

	locationPicker = LocationPicker.getInstance(locationPickersArray);
	locationPickListener = new LocationPicker.Listener() {
		
		public void locationPicked(Picker picker, Landmark location) {
			if(picker==slp){
				//TODO: Change radius field to 30 Miles
				choiceRadius.setSelectedValue(30);
			}
			System.out.println("Landmark: " + location);
		}
	};
	locationPicker.setListener(locationPickListener);
}

 

I have no idea what is going on, and why it won't work.

 

 

Thanks.

Please use plain text.
Developer
weaselgrater
Posts: 87
Registered: ‎08-25-2009

Re: Adding locationPicker throws IllegalStateException

I can't figure this out, does anyone have a clue as to what may be causing this?

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

Re: Adding locationPicker throws IllegalStateException

From where are you calling readyLocationPicker?

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.
Developer
weaselgrater
Posts: 87
Registered: ‎08-25-2009

Re: Adding locationPicker throws IllegalStateException

[ Edited ]

 

        public AdvancedIncidentListOptions()
        {
        	readyComponents();
        	addComponents();
        }

 

The constructor for a subclass of MainScreen,

 

 

private void readyComponents(){
	readyLocationPicker();
	
	choiceRadius = new NumericChoiceField("Radius(mi):", 5, 50, 5, 2);

	timeNumber = new NumericChoiceField("", 1, 20, 1, 0){
		
		public void layout(int width, int height){
            super.layout(width,height);
            setExtent((getWidth()/5),20);       
        }

	};

.....
}

 

Then adding it screwed everything up:

 

 

private void addComponents(){
	LabelField lblLocation = new LabelField("Location:");
	lblLocation.setFont(Font.getDefault().derive(Font.BOLD, Font.getDefault().getHeight() + 2));
	add(new LabelField("Location:"));
	//PROBLEM: add(locationPicker);
	add(choiceRadius);

 

 

 

Please use plain text.
Developer
weaselgrater
Posts: 87
Registered: ‎08-25-2009

Re: Adding locationPicker throws IllegalStateException

Where else could I put this so that it works, (if that is the problem)? Is this a general error that someone understands?

Please use plain text.
Developer
weaselgrater
Posts: 87
Registered: ‎08-25-2009

Re: Adding locationPicker throws IllegalStateException

 Oh, it extends Screen. Silly me. Here's how I got it to work:

 

locationPickerButton = new ButtonField("Location", ButtonField.CONSUME_CLICK | ButtonField.FIELD_RIGHT);
locationPickerButton.setChangeListener(new FieldChangeListener() {
	public void fieldChanged(Field field, int context) {
		
		locationPicker.show();
        locationPickerButton.setLabel(locationPickerLocation.getName());
  
	}
});

 

 

 

Please use plain text.