我只是尝试在我Activity
FragmentActivity
的另一个GoogleMap
上导航。我有InfoWindowClickListener
googleMap.setOnInfoWindowClickListener(new OnInfoWindowClickListener() {
@Override
public void onInfoWindowClick(Marker marker) {
String distance[] = marker.getSnippet().split(" - ");
String distanceString = distance[0];
String idString = marker.getId();
String stationid = markershashmap.get(idString);
Toast.makeText(getApplicationContext(), "Clicked",
Toast.LENGTH_SHORT).show();
Intent dockitdetailsIntent = new Intent(
getApplicationContext(), AnotherActivity.class);
TabGroupActivity parentActivity = (TabGroupActivity) getParent();
dockitdetailsIntent.putExtra("stationId", stationid);
dockitdetailsIntent.putExtra("distance", distanceString);
parentActivity.startChildActivity("Activity Name",
dockitdetailsIntent);
}
});
但是当我点击InfoWindow时,我的设备挂起然后我必须强行关闭没有响应的应用程序。当我使用startActivity(dockitdetailsIntent)
时,它工作正常,但Tab删除。但我想将Next Activity用于类似的标签。请建议我为什么我的设备挂出并且没有响应。
答案 0 :(得分:2)
创建Handler并将Intent逻辑放入如下所示:
mMap.setOnInfoWindowClickListener(new OnInfoWindowClickListener() {
@Override
public void onInfoWindowClick(Marker m1) {
// TODO Auto-generated method stub
try{
String[] str2=str.split("contactID");
Message mesg = new Message();
Bundle b = new Bundle();
b.putString("contact_id", str2[1]);
mesg.setData(b);
handler.sendMessage(mesg);
}catch(Exception e){
e.printStackTrace();
}
}
});
现在创建一个如下所示的处理程序:
private Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
Bundle b = msg.getData();
Bundle b1 = new Bundle();
b1.putString("ContactID", b.getString("contact_id"));
b1.putBoolean("showBack", true);
Intent edit = new Intent(getParent(), ContactDetails2.class);
edit.putExtras(b1);
TabGroupActivity parentActivity = (TabGroupActivity) getParent();
parentActivity.startChildActivity("ContactDetails2", edit);
}
};
试试这个。它在我的案例中工作