In my second activity there is coding of to find current location, but i want to display that location on my first activity text view. So, plz help me. here is my code of second activity in which I find my current location and below this code I paste my First activity coding on which i want to display my current location
public class Trackme extends Activity implements OnMapClickListener {
TextView tv;
GoogleMap googleMap = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.trackme);
tv=(TextView)findViewById(R.id.textView1);
initilizeMap();
googleMap.setOnMapClickListener(this);
}
private void initilizeMap()
{
try{
if (googleMap == null)
{
MapFragment fr = ((MapFragment) getFragmentManager().findFragmentById(
R.id.map));
googleMap = fr.getMap();
googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
googleMap.setMyLocationEnabled(true);
}
}catch(Exception ex)
{
Toast.makeText(this, ex.getMessage(), Toast.LENGTH_LONG).show();
}
}
@Override
public void onMapClick(LatLng arg1)
{
try{
LocationManager mngr = (LocationManager)getSystemService(LOCATION_SERVICE);
Geocoder g =new Geocoder(this, Locale.getDefault());
List<Address> l = g.getFromLocation(arg1.latitude, arg1.longitude, 1);
for(Address adr : l)
{
String countyName = adr.getLocality();
String countyCode = adr.getAddressLine(0);
String c=adr.getAdminArea();
String location="Country is :: "+countyName+" Country Code :: "+countyCode+"state="+c;
tv.setText(location);
Toast.makeText(this,"Country is :: "+countyName+" Country Code :: "+countyCode+"state="+c, Toast.LENGTH_LONG).show();
Intent i= new Intent(this,RegisterNext.class);
i.putExtra("a",location);
setResult(RESULT_OK, i);
startActivityForResult(i,1);
finish();
/*MarkerOptions mrkop = new MarkerOptions();
mrkop.position(new LatLng(arg1.latitude, arg1.longitude));
mrkop.title(countyName);
googleMap.addMarker(mrkop);*/
}
}catch(IOException ex)
{
Toast.makeText(this, ex.getMessage(), Toast.LENGTH_LONG).show();
}
}
}