package com.nds.IamHere;
import java.io.IOException;
import java.util.List;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
import android.app.Activity;
import android.location.Address;
import android.location.Geocoder;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
public class IamHere<Classname> extends MapActivity implements LocationListener {
String nds;
/** Called when the activity is first created. */
private static final String TAG = "LocationActivity";
private static final String TAG1 = "GPS";
private static final String Tag2 = "ADDRESSNDS";
private static final String ndsaddress = null;
LocationManager locationManager;
Geocoder geocoder;
TextView locationText;
/// send sms to :::: 07401942885
@Override
public void onCreate(Bundle savedInstanceState) {
final TextView GPSxp = (TextView)findViewById(R.id.GPSXY);
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
locationText = (TextView)this.findViewById(R.id.lblLocationInfo);
TextView gpsXY = (TextView)this.findViewById(R.id.GPSXY);
TextView addr = (TextView)this.findViewById(R.id.address);
Button sendSMS = (Button)findViewById(R.id.button1);
sendSMS.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
nds = ((Object) locationText.getText()).toString();
//show a toast first!!
//Toast.makeText(this, "Your Toast Text", Toast.LENGTH_SHORT).show();
Toast t;
t = Toast.makeText(IamHere.this, nds, Toast.LENGTH_LONG);
t.show();
}}
);
locationManager = (LocationManager)this.getSystemService(LOCATION_SERVICE);
geocoder = new Geocoder(this);
Location location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
if (location != null) {
Log.d(TAG, location.toString());
this.onLocationChanged(location);
}
}
@Override
protected void onResume() {
super.onResume();
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 10, this);
}
@Override
protected void onPause() {
super.onPause();
locationManager.removeUpdates(this);
}
public void onLocationChanged(Location location) { //<9>
Log.d(TAG, "onLocationChanged with location " + location.toString());
String text = String.format("Lat:\t %f\nLong:\t %f\n", location.getLatitude(),
location.getLongitude());
this.locationText.setText(text);
try {
List<Address> addresses = geocoder.getFromLocation(location.getLatitude(), location.getLongitude(), 2); //<10>
for (Address address : addresses) {
this.locationText.append("\n" + address.getAddressLine(0));
}
int latitude = (int)(location.getLatitude() * 1000000);
int longitude = (int)(location.getLongitude() * 1000000);
GeoPoint point = new GeoPoint(latitude,longitude);
} catch (IOException e) {
Log.e("LocateMe", "Could not get Geocoder data", e);
}
}
@Override
protected boolean isRouteDisplayed() {
return false;
}
@Override
public void onProviderDisabled(String provider) {
// TODO Auto-generated method stub
}
@Override
public void onProviderEnabled(String provider) {
// TODO Auto-generated method stub
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
// TODO Auto-generated method stub
}
}