在我的应用程序中,我将一些意图附加信息从一项活动发送到另一项活动。但是一些用户报告说这些数据总是为零 - 即使我可以看到这些值在发送活动中是好的。
这是发送活动的代码:
Intent intent = new Intent();
intent.setClass(waypointListView.this, addWaypointActivity.class);
intent.putExtra("latitude", String.format("%9.6f", globLatitude));
intent.putExtra("longitude", String.format("%9.6f", globLongitude));
startActivityForResult(intent, ACTIVITY_ADD_WAYPOINT);
这就是它在新活动中的读取方式:
Intent myIntent = getIntent();
String latitudeStr = myIntent.getExtras().getString("latitude");
try{
globLatitude = Float.parseFloat(latitudeStr);
} catch(NumberFormatException nfe) {
globLatitude=0f;
}
String longitudeStr = myIntent.getExtras().getString("longitude");
try{
globLongitude = Float.parseFloat(longitudeStr);
} catch(NumberFormatException nfe) {
globLongitude=0f;
}
在我的两台设备上它都可以正常工作,但我有 3 例客户抱怨它不起作用(记录在视频记录中)。
有什么建议么?