0
GeolocationクラスからloginActivityクラスに経度緯度を送信するには結構ですが、loginActivityのEditTextには何も表示されません これは私が行ったことです。ジオロケーション活性の :他のクラスのedittextに経度緯度fronm geolocatioクラスを送信
public static String lon;
public static String lat;
public void onLocationChanged(Location location) {
Log.i(LOG_TAG, location.toString());
lon = Double.toString(location.getLongitude());
lat = Double.toString(location.getLatitude());
Intent intent = new Intent(this, LoginActivity.class);
intent.putExtra("longitude", lon);
intent.putExtra("latitude", lat);
startActivity(intent);
// etLatitude.setText(lat);
// etLongitude.setText(lon);
}
とLoginActivity:
public static String lon;
public static String lat;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
TextView tvLongitude = (TextView) findViewById(R.id.tvLongitude);
TextView tvLatitude = (TextView) findViewById(R.id.tvLatitude);
Intent in = getIntent();
lon = in.getExtras().getString("longitude");
tvLongitude.setText(lon);
lat = in.getExtras().getString("latitude");
tvLatitude.setText(lat);
}
activity_login.xmlに予め
<TextView
android:hint="Longitude : "
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tvLongitude"
android:layout_below="@+id/tvRegesterHere"
android:layout_marginTop="39dp" />
<TextView
android:hint="Latitude: "
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tvLatitude"
android:layout_below="@+id/tvLongitude"
android:layout_marginTop="39dp" />
おかげ。
私はまだ取得:java.lang.NullPointerExceptionが:上の仮想メソッドを呼び出すための試み 'はjava.lang.String型android.os.Bundle.getString(java.lang.String)を' nullオブジェクト参照 – adily