BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 03-10-2010, 05:26 AM   #1 (permalink)
New Member
 
Join Date: Feb 2008
Model: 8820
PIN: N/A
Carrier: T-mobile
Posts: 12
Post Thanks: 0
Thanked 0 Times in 0 Posts
Unhappy Locator.reverseGeocode not works

Please Login to Remove!

Hi all,

i am working on Map 5.0. And am using Locator.reverseGeocode(latitude, longitude, searchType) to Landmarks.

this is my code,

private Thread reverseGeocode;

public MyReverseGeocode()
{
reverseGeocode = new Thread(thread);
reverseGeocode.setPriority(Thread.MIN_PRIORITY);
reverseGeocode.start();
try {
reverseGeocode.join();
} catch (InterruptedException e) {
e.printStackTrace();
}
}

Runnable thread = new Runnable()
{
public void run()
{

try
{
MapFieldScreen.landmarks = Locator.reverseGeocode((int)IceScreen.latitude * 100000,
(int)IceScreen.longitude * 100000,Locator.ADDRESS);
}
catch ( LocatorException lex )
{
}
}
};

i added join this thread in the calling place, to do painting after getting landmarks.

but am getting, "uncaught exception : Application 178 (myApp) not responsing. Terminated".

Please help me on this,

if have sample working code on this, it wud be more appreciable...!!
Offline  
Old 03-10-2010, 07:38 AM   #2 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default

The Thread.join() will block your event thread until the geocoding operation completes. This causes your applicaiton event queue to fill up, resulting in the exception that you are reporting.

join() is not an acceptable method to synchronize the UI with a background thread. You should look at implementing the Observer interface, or some type if simple callback mechanism that would allow the background thread to update the UI.
Offline  
Old 03-10-2010, 09:18 PM   #3 (permalink)
New Member
 
Join Date: Feb 2008
Model: 8820
PIN: N/A
Carrier: T-mobile
Posts: 12
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

I removed join() and calling repaint in the locator initialization thread once after its done.
Still the result is not observed in simulator. Is it the problem with the simulator?

class MyReverseGeocode
{
private Thread reverseGeocode;

public MyReverseGeocode()
{
reverseGeocode = new Thread(thread);
reverseGeocode.setPriority(Thread.MIN_PRIORITY);
reverseGeocode.start();
// try {
// reverseGeocode.join();
// } catch (InterruptedException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
}

Runnable thread = new Runnable()
{
public void run()
{

try
{
MapFieldScreen.landmarks = Locator.reverseGeocode((int)latitude * 100000,
(int)longitude * 100000,Locator.COUNTRY);
MapFieldScreen.mapScreen.invalidate();
}
catch ( LocatorException lex )
{
}
}
};
}

Still lanmdarks array is null :(

any idea ?
Offline  
Old 03-10-2010, 10:17 PM   #4 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default

One obvious issue is that you are "eating" any exceptions thrown by the Locator class. You need to display the exception there.

System.out.println("Locator error: " + lex.getMessage())

...or something long those lines.
Offline  
Old 03-11-2010, 11:58 PM   #5 (permalink)
New Member
 
Join Date: Feb 2008
Model: 8820
PIN: N/A
Carrier: T-mobile
Posts: 12
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Dougsg38p, thanx for the reply.

I got one landmark when i call ,
Locator.reverseGeocode((int)latitude * 100000,
(int)longitude * 100000,Locator.COUNTRY);

How will we get multiple landmarks by using this method. My intention is to draw 2 - 3 more landmarks in the current location. Like, Hotels in New york. something like that.
I found searchType for the reverseGeocode are CITY,ADDRESS,COUNTRY.... By using these searchType, will i get multiple landmarks?

thanx in advance.
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.