Ah, sorry. Here it is:

Android.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android";
      package="com.example"
      android:versionCode="1"
      android:versionName="1.0.0">
    <application android:icon="@drawable/icon" android:label="@string/
app_name">
        <activity android:name=".GPSTest"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category
android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
<uses-permission
android:name="android.permission.ACCESS_COARSE_LOCATION"></uses-
permission>
<uses-permission
android:name="android.permission.ACCESS_FINE_LOCATION"></uses-
permission>
<uses-permission
android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS"></
uses-permission>
<uses-permission
android:name="android.permission.ACCESS_MOCK_LOCATION"></uses-
permission>
<uses-permission
android:name="android.permission.CONTROL_LOCATION_UPDATES"></uses-
permission>
<uses-permission android:name="android.permission.INTERNET"></uses-
permission>
</manifest>

GPSTest.java:

package com.example;

import android.app.Activity;
import android.content.Context;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.util.Log;

public class GPSTest extends Activity implements LocationListener {

    private LocationManager lm;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        lm = (LocationManager) getSystemService
(Context.LOCATION_SERVICE);
        lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1l,
1l, this);
    }

        @Override
        public void onLocationChanged(Location arg0) {
                String lat = String.valueOf(arg0.getLatitude());
                String lon = String.valueOf(arg0.getLongitude());
                Log.e("GPS", "location changed: lat="+lat+", lon="+lon);
        }
        public void onProviderDisabled(String arg0) {
                Log.e("GPS", "provider disabled " + arg0);
        }
        public void onProviderEnabled(String arg0) {
                Log.e("GPS", "provider enabled " + arg0);
        }
        public void onStatusChanged(String arg0, int arg1, Bundle arg2) {
                Log.e("GPS", "status changed to " + arg0 + " [" + arg1 + "]");
        }
}

and finally, main.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
        <TextView
                android:id="@+id/label1"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:text="@string/hello"
            />
</LinearLayout>

On Jan 26, 5:16 pm, "Justin (Google Employee)" <[email protected]>
wrote:
> Have you declared the appropriate permissions? Code would be useful
> here.
>
> Cheers,
> Justin
> Android Team @ Google
>
> On Jan 26, 1:33 pm, octagon <[email protected]> wrote:
>
> > Hello,
>
> > Is there any android example code for the GPS location manager that
> > has been demonstrated to actually work with the G1? I have been able
> > to get the emulator to work with no issues, but the G1 stays in
> > TEMPORARILY_UNAVAILABLE status forever. GPS is actually working okay
> > on the phone in the Maps application. I'm going through the android
> > source code tracking down exactly what Maps is doing, but it's kind of
> > slow going and it would be very helpful to be able to see a known-good
> > GPS example. Thanks!
>
> > Micha
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to