クラスを介してデータ/変数を渡す方法を知りたいですか?
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 基本的に、onCreate に CurrentLocation() があり、次に HTTPPOST スクリプトがありsendDataDetail
ます。そして、場所を取得するクラスがあります。
その場所を取得して に送信するにはどうすればよいsendDataDetail
ですか? どのような方法をとればよいですか?
私はまだアンドロイドを学んでいることに注意してください。
前もって感謝します!