I'm wondering how to pass data/variables through classes?
Class.java
public class AddItem extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState) {
mlocManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
mlocListener = new CurrentLocation();
mlocManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, mlocListener);
}
}
public void sendDataDetail(View v){
// This is where my HTTPPOST goes, need the location here
}
public class CurrentLocation implements LocationListener {
@Override
public void onLocationChanged(Location loc) {
// TODO Auto-generated method stub
loc.getLatitude();
loc.getLongitude();
String Text = "My Current Location is: " + "Lat = " + loc.getLatitude() + "Long = " + loc.getLongitude();
Toast.makeText(getApplicationContext(),Text,Toast.LENGTH_SHORT).show();
}
}
SO basically, I have CurrentLocation() in onCreate, and then I have an HTTPPOST script in sendDataDetail
. And then I have a class that gets the location.
How do I get that location and send it to sendDataDetail
? What methods should I take?
Please note that I'm still learning android,
Thank you in advance!