다음 사용할 수 있습니다. 이 솔루션은 MapActivity 컨텍스트에서 "startActivity"를 호출하는 것에 의존합니다.
지도가 실제로 오버레이와 함께 작동하는 경우 이미 MapView Context를 사용자 지정 ItemizedOverlay 생성자에 전달했으며 mContext라는 클래스 변수에 MapView Context를 할당했을 것입니다 (Google의 MapView 예제를 따랐다는 가정을하고 있음)).
@Override
protected boolean onTap(int index) {
Intent intent = new Intent(mContext, ActivityYouAreTryingToLaunch.class);
mContext.startActivity(intent);
return true;
}
을하지만 당신은 아마 당신이 이렇게 새로운 활동이 당신의 선택에 유용한 일을 할 수있는 시작하려는 새로운 활동에 뭔가를 전달하려는 : 그래서 사용자 정의 오버레이의 ONTAP 기능으로,이 작업을 수행. 그래서 ...
@Override
protected boolean onTap(int index) {
OverlayItem item = mOverlays.get(index);
//assumption: you decided to store an "id" in the snippet so you can associate this map location with your new Activity
long id = Long.parseLong(item.getSnippet()); //Snippet is a built-in String property of an Overlay object.
//pass an "id" to the class so you can query
Intent intent = new Intent(mContext, ActivityYouAreTryingToLaunch.class);
String action = Intent.ACTION_PICK; //You can substitute with any action that is relevant to the class you are calling
//I create a URI this way because I append the id to the end of the URI (lookup the NotePad example for help because there are many ways to build a URI)
Uri uri = ContentUris.withAppendedId(Your_CONTENT_URI, id);
//set the action and data for this Intent
intent.setAction(action);
intent.setData(uri);
//call the class
mContext.startActivity(intent);
return true;
}
= ( – Cid
) ItemizedOverlay 클래스는 활동이 아니므로 컨텍스트를 사용하여 해당 기능을 추가 할 수 있습니다. – CQM