0

In my Java ME app, LocationProvider.getInstance(null) always returns me null in emulator.

App in early state, so I didn't tried on real phone.

I believe, I read every article about Location API, but I still don't get, why it's happening to me.

It works fine in different projects, with same settings on same emulator.

Here's the code:

if(currentLp == null) 
{
     try 
     {
         System.err.println("nope");
         currentLp = LocationProvider.getInstance(null);
     } catch (LocationException ex) 
     {
          System.err.println("Ooops!");
     }
 }

CLDC-1.1, MIDP-2.1, Location API 1.0 on DefaultCLDCPhone01 from SDK3.0

gabr
  • 26,580
  • 9
  • 75
  • 141
leorik
  • 1
  • Which emulator are you using? Does it actually provide a LocationProvider? Which "different projects" does it "work fine" in? Have you run those projects personally on your install of your emulator and seen them working? – funkybro Mar 18 '11 at 08:05
  • I wrote, I use DeafultCLDCPhone01. If it doesn't provide, it will throw exception, according to JSR293. And update - it starts working on CalmshellCldcPhone. And not working on DefaultCLDCPhone in other project. –  Mar 18 '11 at 08:30

1 Answers1

0

CLDC-1.1, MIDP-2.1, Location API 1.0 on DefaultCLDCPhone01 from SDK3.0

LAPI 1.0 - JSR 179. In this version specification, LocationProvider.getInstance returns null "if a LocationProvider that meets the defined criteria can't be returned but there are other supported available or temporarily unavailable providers that do not meet the criteria."

...If it doesn't provide, it will throw exception, according to JSR293

oops JSR293? That's LAPI 2.0 not 1.0. Whatever it specifies, it has nothing to do with your case since as you wrote, it supports earlier version specification. For what to expect in your case, use JSR 179. Or configure DefaultCLDCPhone to support JSR 293 if that's possible (that should be in emulator User Guide)

gnat
  • 6,213
  • 108
  • 53
  • 73