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. Need guidance in making the game's logic supporting multiple screens.

Hi.

I've read the article "Supporting Multiple Screen" on Android
developers site. But that doesn't apply to game logic.

Let me get straight to the point. My situation is as follows:

- I'm creating a game using LunarLander code as a base.

- In my game, there'll be an object flying up from the bottom of the
screen. The object will fly in projectile motion.

- I set the starting velocity, gravity and angle so that the highest
point(of projectile motion) is almost at the top of the screen.

- The screen tested is Motorola Milestone. (480x854 resolution)
Meaning the object travels around 854 pixels vertically.

--- Problem ---
When I test the game on small device (Android Dev Phone 1/G1) which is
320x480.(has only 480 pixels vertical)  The object fly out of the
screen because it is set to travel for 854 pixels.

I'm thinking of adjusting starting velocity based on screensizes. But
that sounds unreliable when we've so many devices/resolutions out
there.

How do you combat these kind of problem when making games?

Thank you in advance!

-- 

2. How to open a new Activity in a new "window" (calling a new activity)?

Hi there,

sorry for the following explanation... I just didn't know how to describe it
differently...

What I would like to do is when I click a certain button, my app should open
a new "window" and loading the selected content into this new window/view.
It shouldn't be like e.g. the send intent, which opens a completely
different, but still be part of my app just showing a completely new view...

 I just don't know right now, what I have to do or even if this is possible,
so if anyone could help me or direct into the correct direction or knows a
great tut for that...any sort of help is more than welcome...

Thank you very much

-- 

3. Build performance of 2.2 vs older sdk implementations

4. Device Seeding Program for Top Android Market Developers

5. Device Seeding Program for Top Android Market Developers

6. HELP!!! APLIKASI MARKET HILANG>>PLEASEE

7. Solved WTA Droid tidak bisa masuk recovery