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. HttpClient

Hi,

We are using  the code

HttpClient client = new HttpClient();
PostMethod method = new PostMethod(url.toString());
method.addParameter(CommonConst.XML_REQUEST_PARAM_KEY, xmlRequest);
method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER,
                                new DefaultHttpMethodRetryHandler(3, false));

for network access. However if the specified server is not up and
running, the code is not throwing any exception and does not return.

Is there a way to say timeout so that exception could be thrown..

Regards,
Raja Nagendra Kumar,
C.T.O
www.tejasoft.com

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

2. Tcp socket within 2 emulators

Hi there, strate01234! Unfortunately I don't know how to solve your
problem, but I'm working with similar project. And almost for day I'm
trying to connect my android app with backend java program(server).
When I try to create a socket with command socket = new
Socket("en3rgizer", 8888); emulator throws null pointer exception.
Would you be so kind to post your piece of code where you connect to
java program server, and a code where server accepts connection?
Thanks in advance.


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

3. Issues when rotating PNG image with transparency

4. to phone

5. Possible scrolling bug in ListView using navigational key pads.

6. accessing a web service

7. Please Help - SMS program