Я пытаюсь использовать данные о местоположении. Я получаю в одном действии для вычисления в другом и для передачи данных. Я пытаюсь использовать намерение. Однако, когда я пытаюсь добавить Намерение, я получаю ошибкуIntent 'Невозможно разрешить конструктор' при попытке переноса double
«Не удается разрешить конструктор»
своей деятельности я пытаюсь передать данные из выглядит следующим образом:
import android.content.Intent;
import android.location.Location;
import android.location.LocationListener;
import android.os.Bundle;
import android.util.Log;
public class CurrentLocationListener implements LocationListener {
@Override
public void onLocationChanged(Location location)
{
if(location != null)
{
Double currentLat = location.getLatitude();
Double currentLong = location.getLongitude();
Log.e("Latitude :", "" + location.getLatitude());
Log.e("Longitude :", "" + location.getLongitude());
Intent intent = new Intent(this, MainActivity.class);
intent.putExtra("Lat", currentLat);
intent.putExtra("Long", currentLong);
CurrentLocationListener.this.startActivity(intent);
}
}
И это то, где я пытаюсь использовать данные в другой деятельности:
public class MainActivity extends Activity implements SensorEventListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
parseButton.setOnClickListener(
new Button.OnClickListener()
{
public void onClick(View inputButtonView)
{
String latInputString = latFind.getText().toString();
String longInputString = longFind.getText().toString();
double latInputDouble = Double.parseDouble(latInputString);
double longInputDouble = Double.parseDouble(longInputString);
double dLon = (longInputDouble-currentLong);
double y = Math.sin(dLon) * Math.cos(latInputDouble);
double x = Math.cos(currentLat)
*Math.sin(latInputDouble) - Math.sin(currentLat)
*Math.cos(latInputDouble)*Math.cos(dLon);
double targetBearing = Math.toDegrees((Math.atan2(y, x)));
targetBearing = (360 - ((targetBearing + 360) % 360));
}
});
Итак, вот что я спрашиваю: как правильно перенести данные Double для Latitude и Longitude из одной активности в другую?
Я тоже ломал мой мозг о том, как правильно перезванивать, что в комплект data – user6357574