[英]intent from marker info window
I am trying to open an activity on android´s app clicking map marker´s info window info info but I can´t, here is my code: 我试图在Android的应用程序上单击地图标记的信息窗口信息信息以打开活动,但是我做不到,这是我的代码:
googleMap.setOnInfoWindowClickListener(new OnInfoWindowClickListener() {
public void onInfoWindowClick(Marker marker) {
Intent in = new Intent(MyActivity.this,
OtherActivity.class);
in.putExtra("title", marker.getTitle());
}
});
Thank you so much. 非常感谢。
You forget to start Activity
like 你忘了像这样开始Activity
Youractivity.this.startActivity(in);
and try another way 然后尝试另一种方式
googleMap.setOnInfoWindowClickListener(new OnInfoWindowClickListener() {
public void onInfoWindowClick(Marker marker) {
Message mesg = new Message();
Bundle b = new Bundle();
b.putString("title", marker.getTitle());
mesg.setData(b);
handler.sendMessage(mesg);
}
});
Now create Handler
for that like so. 现在像这样创建Handler
。
private Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
Bundle b = msg.getData();
Intent in = new Intent(MyActivity.this,OtherActivity.class);
in.putExtra("title", b.getString("title"));
Youractivity.this.startActivity(in);
}
};
The problem that it is not starting because you didnt start the activity using the startActivity
method of the UI thread. 它没有启动的问题是因为您没有使用UI线程的startActivity
方法启动活动。
solution: 解:
MyActivity.this.startActivity(in);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.