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
Developer
gopi_riar
Posts: 54
Registered: ‎10-05-2012
My Device: blackberry curve 9300
My Carrier: Vodafone
Accepted Solution

Interrupted Exception in getting Location??

hi..

 

My application run in background which gets location through gps and cellsite .. it shows me interrupted exception when i run the application ..How can i start both the threads together ??? is there any way .. how to handle this exception??

Please use plain text.
New Contributor
bgibbons
Posts: 7
Registered: ‎11-07-2011
My Device: Bold 9900
My Carrier: Bell

Re: Interrupted Exception in getting Location??

Hi.  Can you please post the code that is causing this exception?

Please use plain text.
Developer
peter_strange
Posts: 19,595
Registered: ‎07-14-2008
My Device: Not Specified

Re: Interrupted Exception in getting Location??

I agree the code, specifically the criteria you are using, will be helpful.  Can you also tell us how long it takes before you get this exception, what the device is and if it is a full BlackBerry enabled device.  . 

Please use plain text.
Developer
gopi_riar
Posts: 54
Registered: ‎10-05-2012
My Device: blackberry curve 9300
My Carrier: Vodafone

Re: Interrupted Exception in getting Location??

I m using blackberry curve 9300.. 6.0.0 bundle .. here is the code

 

BlackBerryLocation location;
    QualifiedCoordinates qualifiedCoordinates;
    String data;
    BlackBerryLocationProvider provider;

 

 

BlackBerryCriteria myCriteria = new BlackBerryCriteria(GPSInfo.GPS_MODE_AUTONOMOUS);

 

              provider = (BlackBerryLocationProvider) LocationProvider.getInstance(myCriteria);
                    location = (BlackBerryLocation) provider.getLocation(150);
                    // provider = (BlackBerryLocationProvider)
                    // LocationProvider.getInstance(myCriteria);

                    if (location != null) {
                        qualifiedCoordinates = location
                                .getQualifiedCoordinates();
                        data = "Lat: " + qualifiedCoordinates.getLatitude();
                        data += "Lon: " + qualifiedCoordinates.getLongitude();
                        if (data.equals(null) || data == null)
                            data = "0";

                        strLat = String.valueOf(qualifiedCoordinates
                                .getLatitude());
                        strLon = String.valueOf(qualifiedCoordinates
                                .getLongitude());

                        strSatCount = String.valueOf(location
                                .getSatelliteCount());

                      

                        strStamp = String.valueOf(location.getTimestamp());
                        

                        System.out.println(data);
                        Log.write(data);
                    }
                }

            } catch (LocationException e) {

                Log.write("GPSHandler Location Exception" + " : "
                        + e.getMessage());


            } catch (InterruptedException e) {

                Log.write("GPSHandler Interrupted Exception" + " : "
                        + e.getMessage());

            }

 

 

and i am using the same code for cellsite only changing this:

BlackBerryCriteria myCriteria = new BlackBerryCriteria(GPSInfo.GPS_MODE_CELLSITE);

Please use plain text.
Developer
peter_strange
Posts: 19,595
Registered: ‎07-14-2008
My Device: Not Specified

Re: Interrupted Exception in getting Location??

Do you call this code only once?  Or can you start multiple Threads?

 

How long before the Exception is thrown?

 

I would put some System.out.println lines in this code and then debug on device, to track the time a location is started and finished and also to check that you do this only one at a time.

Please use plain text.
Developer
gopi_riar
Posts: 54
Registered: ‎10-05-2012
My Device: blackberry curve 9300
My Carrier: Vodafone

Re: Interrupted Exception in getting Location??

[ Edited ]

i have added a while loop over it in which thread sleep for 3 minutes and  it runs while the condition is true similar for cellsite  and it is working when i run both when i run only one of them ...

 

 

but know for the timing .. i dont know exception handling as much .. i just called the cellsite thread in the gps thread location exception so when gps doesn't provide the location or timed out at that time it runs the cellsite thread... i dont know may be it can cause any problem after that ....

Please use plain text.
Developer
peter_strange
Posts: 19,595
Registered: ‎07-14-2008
My Device: Not Specified

Re: Interrupted Exception in getting Location??

Glad that is working.

 

Your approach of trying for Cell Site location when GPS does not work seems fine.  I would consider doing the reverse if you don't need an accurate location.  If you need accuracy, then of course GPS is the way to go...

Please use plain text.