Java 我的intent.putExtras(无法解析字符串)有什么问题?
我需要把地址传给谷歌地图。我已将所有数据传递给DisplayItem活动。现在,从Displayitem活动中,我只想将地址传递给MapActivity 这是我成功显示所有数据的活动。之后,我创建了一个按钮,用户可以转到mapActivity查看位置Java 我的intent.putExtras(无法解析字符串)有什么问题?,java,android,google-maps,Java,Android,Google Maps,我需要把地址传给谷歌地图。我已将所有数据传递给DisplayItem活动。现在,从Displayitem活动中,我只想将地址传递给MapActivity 这是我成功显示所有数据的活动。之后,我创建了一个按钮,用户可以转到mapActivity查看位置 private Bundle extras; private TextView mallAddress; private TextView tvMallName; private TextView state, url, phone_number
private Bundle extras;
private TextView mallAddress;
private TextView tvMallName;
private TextView state, url, phone_number, mail,wb,pn, town;
ImageView map_Locations;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_displayitem);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
tvMallName = (TextView) findViewById(R.id.tv_mallname);
state = (TextView) findViewById(R.id.states);
mallAddress = (TextView) findViewById(R.id.mall_Address);
map_Locations= (ImageView) findViewById(R.id.map_location);
extras = getIntent().getExtras();
String malladress = extras.getString(EXTRA_ADDRESS,"");
String mallName = extras.getString(EXTRA_NAME, "");
String mallstate = extras.getString(EXTRA_STATE,"");
mallAddress.setText(malladress);
tvMallName.setText(mallName);
state.setText(mallstate);
}
这是我创建的按钮(我的字符串“地址”有问题),我做错了吗?它故意说(无法解析字符串,字符串)。putExtras()
在MapActivity上,我检索数据
private void getAddress(GoogleMap googleMap) {
try {
mMap = googleMap;
Intent intent = getIntent();
extras = intent.getExtras();
Geocoder geocoder = new Geocoder(this);
address = extras.getString(this.EXTRA_ADDRESS);
location = geocoder.getFromLocationName(address, 1);
if (location.size() > 0) {
lati =location.get(0).getLatitude();
lon =location.get(0).getLongitude();
MarkerOptions options = new MarkerOptions()
.title(name)
.position (new LatLng(lati, lon));
mMap.addMarker(options);
}
}catch (Exception e){
e.printStackTrace();
}
}
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
getAddress(googleMap);
setUpMap();
}
ps.我是新手不是
intent.putExtras(...);
它只是intent.putExtra(…)
检查一下我现在笑得很大声。哈哈哈。我太傻了。天哪。。哈哈,谢谢你叫醒我up@Critako休息一下,吃点点心。
intent.putExtras(...);
intent.putExtra(MapsActivity.EXTRA_ADDRESS, address);