@kris : Sorry.....
I'll start again.....

I have problem with my GPS location application........my application
is not able to retrieve latitude and longitude... I'm providing the
code  for your reference.....the below application is launching
successfully on emulator but unable to retrieve the values into Text
View.........I have tried passing values from Emulator Control and
through command line via TELNET....then with Geo-points....please go
through the code......and tell me where i have gone wrong.......


Files are as follows........

1) gps.java

package d.gps;

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

public class gps extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        LocationManager locationManager;
        locationManager =
(LocationManager)getSystemService(Context.LOCATION_SERVICE);
        Location location =
locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);

        updateWithNewLocation(location);
        }
    /** Update UI with a new location */
    private void updateWithNewLocation(Location location) {
          TextView myLocationText =
(TextView)findViewById(R.id.myLocationText);

          String latLongString;

      if (location != null) {
            double lat = location.getLatitude();
            double lng = location.getLongitude();
            latLongString = "Lat:" + lat + "\nLong:" + lng;
          } else {
            latLongString = "No location found";
          }

          myLocationText.setText("Your Current Position is:\n" +
latLongString);
        }

}

2) 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/myLocationText"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/hello"
  />
</LinearLayout>

3)String.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="hello">Hello World, gps!</string>
    <string name="app_name">gps</string>
</resources>

4) androidmanifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android";
      package="d.gps"
      android:versionCode="1"
      android:versionName="1.0">
    <application android:icon="@drawable/icon" android:label="@string/
app_name">
        <activity android:name=".gps"
                  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-sdk android:minSdkVersion="9" />
  <uses-permission android:name="android.permission.INTERNET"></uses-
permission><uses-permission
android:name="android.permission.ACCESS_FINE_LOCATION"/>

</manifest>

thanks.........

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to