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
Highlighted
Developer
Posts: 101
Registered: ‎05-11-2009
My Device: 9000
Accepted Solution

LocationProvider.getInstance returns null for CELL location positioning

Hi guys.

 

I am having an issue when trying to get a cell network (MS-Based) location to work on my BlackBerry Bold 9000. 

 

Both Assisted and Standalone GPS are working (outside ofcourse), but I am trying to find a way how to get positioning inside the building. 

 

Here is what I am setting for criteria:

 

 

Criteria criteria = new Criteria(); criteria.setHorizontalAccuracy(Criteria.NO_REQUIREMENT); criteria.setVerticalAccuracy(Criteria.NO_REQUIREMENT); criteria.setCostAllowed(true); criteria.setPreferredPowerConsumption(Criteria.POWER_USAGE_LOW); LocationProvider.getInstance(criteria); //<-- Returns null on real device

 

 When I am running on a real device it always gives me null, when I am doing the same on simulator, then it works:

 

 

 

CELL_GPS.png 

 

 What I am doing wrong ? I really need to find a way to make it work indoors.

 

 Thanks for any input. 

 

 

Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: LocationProvider.getInstance returns null for CELL location positioning

I don't see where this is supported on the Bold - likely it depends on your network.

 

See the attached:

 

http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800703/What_Is...

 

 

 

Developer
Posts: 44
Registered: ‎06-16-2009
My Device: Not Specified

Re: LocationProvider.getInstance returns null for CELL location positioning

[ Edited ]

Hey Dominator,

 

I'm going to be real straightforward with you, and try to save you ALOT of time.

 

Basically, cell-tower positioning does not work out of the box on the Blackberry platform (except in a few rare device/carrier setups). So, you can basically throw away the code you have above. If you are in need of indoor location detection, you will need access to a celltowerId database. These databases contain the tower information (cellId,mnc,mcc,lac) and its approximate position (lat/lng coordinates). This will give your application a rough estimate (within a mile or so) of the device's current location.

 

There are open source and professional databases available. Here is one open source database that works on GSM networks (of course, it does not have 100% coverage of all towers yet). The biggest downfall is it does not support CDMA networks (Sprint/Verizon).

 

http://opencellid.org

 

You will find that most people on this board are not very helpful when it comes to cellTower positioning information, so you will need to research, research, research.

 

Best of Luck

Message Edited by rrey2279 on 08-31-2009 05:07 PM
Developer
Posts: 101
Registered: ‎05-11-2009
My Device: 9000

Re: LocationProvider.getInstance returns null for CELL location positioning

Thank you for your response.

 

I had my doubdt's about this, just wanted to make sure.Thanks for the link I will check it.

New Developer
Posts: 3
Registered: ‎01-02-2010
My Device: Not Specified

Re: LocationProvider.getInstance returns null for CELL location positioning

[ Edited ]

hi,

 

im in switzerland, and im pretty sure that my provider (orange) supports assisted / cell location positioning, purely because when i start up google maps, it tells me my position within say 2000 meters. even if im inside. only when i can see the sky, do i get a position within say 10 meters.

 

but my j2me app which i have written ONLY works outside.

 

does anyone know if blackberry handsets only let you use pure GPS if you use j2me?

 

im wanting to publish my app for all java enabled midp2.0 / cldc1.1 phones, so i dont want to start using any special BB APIs.

 

how come googleMaps can give me a location if im inside, but a j2me locationProvider cannot?

 

cheers,

ant

 

Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: LocationProvider.getInstance returns null for CELL location positioning

Google Maps uses google's own tower position database.

 

New Developer
Posts: 3
Registered: ‎01-02-2010
My Device: Not Specified

Re: LocationProvider.getInstance returns null for CELL location positioning

[ Edited ]

I dont quite understand. Do they get some kind of location from the LocationProvider class and then check with their database as to where you are?

 

Because when Im inside, I dont get ANY information from the LocationProvider class. It just times out continueously (or the listener receives no data).

 

Where would I get the cell data? In the extras within the Location?

 

Or does BB provide some different API which gives you this info?

 

Something else I noticed while I was out and about today was that if I start my app when im still inside and then go outside, I dont always get a location - often the app simply keeps timing out. If I restart my app, I get a location almost straight away. Is there something in the docs which says if you get a timeout, you should re-instantiate the LocationProvider?

 

Cheers,

Ant

Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: LocationProvider.getInstance returns null for CELL location positioning

Google does not rely on LocationProvider - the have an alternate location method which retrieves the cell tower ID and hits their database of known cell tower locations.  They *will* use LocationProvider once there is a more accurate location available.

 

When using autonomous GPS, you need a clear line-of-site to 3 satellites to get a fix. Generally, this fails if you are indoors.

 

There is a "status change" event when you go into or out of coverage using the LocationProvider. This requires that you reset the provider.

 

 

 

Contributor
Posts: 12
Registered: ‎07-06-2010
My Device: 8520
My Carrier: airtel

Re: LocationProvider.getInstance returns null for CELL location positioning

[ Edited ]

pls hep me i got the exception when i run in my emulator

 

myLocationProvider=null
exception====java.lang.NullPointerException

 

 and

i ran on 8520 device for testing its shows nothing

after that i had done a debug on device ==== it shows the same error in console pls help me

 

myLocationProvider=null
exception====java.lang.NullPointerException

 

 

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.location.*;
public class GPSMain extends MIDlet
{
    private Display display;
    Mycanvas canvas;
    public GPSMain()
    {
        display = Display.getDisplay(this);
        canvas = new Mycanvas();
    }
    public void startApp()
    {
        display.setCurrent(canvas);
    }
    public void pauseApp(){}
    public void destroyApp(boolean a){}
}

class Mycanvas extends Canvas implements CommandListener
{
    Alert positionAlert;
    public Mycanvas()
    {
       try
        {
            Criteria myCriteria = new Criteria();
            LocationProvider myProvider = LocationProvider.getInstance(myCriteria);

            System.out.println("myLocationProvider="+myProvider);
            Location myLoc = myProvider.getLocation(60);
            double lat = myLoc.getQualifiedCoordinates().getLatitude();
            double lng = myLoc.getQualifiedCoordinates().getLatitude();
            positionAlert = new Alert("Location Error");
            positionAlert.setString("lat="+lat+"  lng="+lng);
            positionAlert.setTimeout(Alert.FOREVER);
        }
        catch(Exception e)
        {
            System.out.println("exception===="+e);
            positionAlert = new Alert("Location Error");
            positionAlert.setString(""+e);
            positionAlert.setTimeout(Alert.FOREVER);
        }
        
    }
    
    
    public void paint(Graphics g)
    {}
    
    public void commandAction(Command command, Displayable displayable)
    {}
}

Contributor
Posts: 12
Registered: ‎07-06-2010
My Device: 8520
My Carrier: airtel

Re: LocationProvider.getInstance returns null for CELL location positioning

Hello Everyone,

 

                               i solved the doudt from a guy whose name is Rishab as he post the link

 

You need to set gps location in simulator please follow steps as mentioned in following URL.

 http://supportforums.blackberry.com/t5/Testing-and-Deployment/Simulating-GPS-location/ta-p/491885

 

BUT its really works on emulator 8820 JDE.It doesnt work on my 8520 DEVICE, i ran the program as debug on device & then i got the error in console as

 

myLocationProvider=null
exception====java.lang.NullPointerException

 

is there any settings required on my 8520 device to get the current location as i m using my airtel network provider (as in j2me device its gives the current location).pls provide me help...

thanks a lot..........................................................................................................................