私は最終プロジェクトに取り組んでおり、Android は初めてです。LocationManager から Activity に速度を渡したいのですが、 Intent で渡そうとしましたが、つまり ( Intent j = new Intent(this, CallblockingActivity.class)
) ですが、うまくいきません。私を助けてください。
public class ShowLocationActivity extends Activity {
private TextView latituteField;
private TextView longitudeField;
private TextView speed;
public float a;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.locationmanager);
latituteField = (TextView) findViewById(R.id.TextView02);
longitudeField = (TextView) findViewById(R.id.TextView04);
speed = (TextView)findViewById(R.id.textspeed);
LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
LocationListener ll = new mylocationlistener();
lm.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, ll);
}
private class mylocationlistener implements LocationListener {
@Override
public void onLocationChanged(Location location) {
if (location != null) {
float lat = (float) (location.getLatitude());
float lng = (float) (location.getLongitude());
latituteField.setText(String.valueOf(lat));
longitudeField.setText(String.valueOf(lng));
a=location.getSpeed();
speed.setText("current speed" + a);
*** **My problwm is here,I just want to pass a**
Log.d("LOCATION CHANGED", location.getLatitude() + "");
Log.d("LOCATION CHANGED", location.getLongitude() + "");
Toast.makeText(ShowLocationActivity.this,
location.getLatitude() + "" + location.getLongitude(),
Toast.LENGTH_LONG).show();
}
}
@Override
public void onProviderDisabled(String provider) {
}
@Override
public void onProviderEnabled(String provider) {
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
}
}
}