LocationManager

by dave.marsden » Sun, 09 Nov 2008 17:14:58 GMT


Sponsored Links
 I'm trying to get some basic location code working, I've started from
the standard hello world type app, and have changed it to print the
current location. with the following code.

package com.android.tracker;

import android.app.Activity;
import android.os.Bundle;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.location.Criteria;
import android.location.Location;
import android.location.LocationManager;
import android.widget.TextView;

public class AndroidTracker extends Activity {
   /** Called when the activity is first created. */
   @Override
   public void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       TextView tv = new TextView(this);
       LocationManager lm =
(LocationManager)getSystemService(Context.LOCATION_SERVICE);

       Location loc = lm.getLastKnownLocation("GPS");
       String pos = loc.toString();
       tv.setText(pos);
       setContentView(tv);
   }
}


However the getLastKnownLocation is returning null in the emulator.
Can anybody tell me what I'm doing wrong?

Thanks

Dave.

--~--~---------~--~----~------------~-------~--~----~



LocationManager

by dave.marsden » Sun, 09 Nov 2008 17:15:07 GMT


 I'm trying to get some basic location based stuff working in the
Android Emulator. using the following code.

package com.android.tracker;

import android.app.Activity;
import android.os.Bundle;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.location.Criteria;
import android.location.Location;
import android.location.LocationManager;
import android.widget.TextView;

public class AndroidTracker extends Activity {
   /** Called when the activity is first created. */
   @Override
   public void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       TextView tv = new TextView(this);
       LocationManager lm =
(LocationManager)getSystemService(Context.LOCATION_SERVICE);

       Location loc = lm.getLastKnownLocation("GPS");
       String pos = loc.toString();
       tv.setText(pos);
       setContentView(tv);
   }
}

However getLastKnownLocation is returning NULL, can anybody explain
what I'm doing wrong please?

Thanks

Dave

--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


LocationManager

by Christine » Sun, 09 Nov 2008 20:46:05 GMT


 The emulator doesn't have a gps device. If you want to test it, you
have to use the location test tools that come with the sdk. In
Eclipse, there's a tool in DDMS that allows you to enter gps
coordinates for the emulator. Here ( http://kurl.nl ?44FE) is a tool
that converts locations to gps coordinates.

On Nov 8, 9:03pm, "dave.marsden" <[EMAIL PROTECTED]


--~--~---------~--~----~------------~-------~--~----~



LocationManager

by Vee » Fri, 09 Jan 2009 00:01:16 GMT


 I was trying to create a mock location manager and i found out that
some of the methods were removed in 1.0 SDK.

Can someone give me a solution on how to implement one? This is just a
sample app i am trying to write, so any help in that regard is helpful
as well.

Thanks !

--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Stk no icon

Dah instal.di manage application dah Ada.
Tapi GA ada iconnya.
Kira2 masalahnya dmn ya?

-- 
"Indonesian Android Community [id-android]" 

2. Oot ada yang di mega bazaar?

Eniwan?
Sent from my BlackBerry smartphone from Sinyal Bagus XL, Nyambung Teruuusss...!

-- 
"Indonesian Android Community [id-android]" 

3. Override enableMyLocation in MyLocationOverlay

4. Solved WTA: Cara backup apps/apk di N1

5. Help with sound aplication

6. Modaco NexusDesire alpha 11

7. Piracy sucks, or does it?