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. paging androiders makassar

mhn info dr teman2 makassar, apa jaringan 3 available disana? kl tdk, bs
infokan operator apa yg reliable disana?
ada rencana business trip kesana soalnya..thanks

-- 
===============

2. [ASK] Charting and SVG in android

Hello. I need your help. I want to make an application in android that
has a charting features and a map. I have a plan to use SVG in my
application in the future. But I'm just a newbie in android. Anyone
can help me finding a charting library or how to use SVG in android??

I want to make a representation data in various of chart and one of
them use a map that I want to view data on this map. Anyone has a try
before or Somebody can help me. Thanks for the attention.

-- 

3. What happens when i change the kernel config file and build the OS with the changed kernel config file?

4. Fwd: WTS: Android Accessories & WinMo Phones

5. What does/does not belong in WidgetProvider

6. exporting signed apk in Eclipse

7. Adding a new View causing Force Close