カスタム ItemizedOverlay クラスの AlertDialog から、どのアクティビティ (クラス名) がカスタム ItemizedOverlay クラスを開始したかを調べる方法を知りたいです。さまざまな場所の MapView でさまざまな活動をしています。MapView が読み込まれると、すべてのアクティビティが自動的に ItemizedOverlay クラスを開始します。そのため、Extra を意図することはできません。
これが可能かどうか誰にもわかりますか?
これが私の ItemizedOverlay コンストラクター クラスです (コメント部分と alertdialog メッセージ部分は無視してください):
public class CustomItemisedOverlay extends ItemizedOverlay<OverlayItem> {
private ArrayList<OverlayItem> mapOverlays = new ArrayList<OverlayItem>();
private Context context;
public CustomItemisedOverlay(Drawable defaultMarker) {
super(boundCenterBottom(defaultMarker));
// TODO Auto-generated constructor stub
}
public CustomItemisedOverlay(Drawable defaultMarker, Context context) {
this(defaultMarker);
this.context = context;
}
@Override
protected OverlayItem createItem(int i) {
// TODO Auto-generated method stub
return mapOverlays.get(i);
}
@Override
public int size() {
// TODO Auto-generated method stub
return mapOverlays.size();
}
//AlertDialog for driving directions here
@Override
protected boolean onTap(int index) {
AlertDialog.Builder dialog = new AlertDialog.Builder(context);
//Title of AlertDialog
dialog.setTitle("Driving Directions");
//Message of AlertDialog
String className = getClass().getSimpleName().toString();
dialog.setMessage(className);
//Positive Button
dialog.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// Handle launch of driving directions here
/*String tappedLong = null;
String tappedLat = null;
String className = this.getClass().getSimpleName().toString();
if(className == "amkActivity") {
tappedLong = "1.363414";
tappedLat = "103.9370256";
} else if (className == "bedokActivity") {
tappedLong = "1.3248498";
tappedLat = "103.9370256";
}
Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse("http://maps.google.com/maps?daddr=" + tappedLat + "," + tappedLong));
context.startActivity(intent);*/
}
});
//Negative Button
dialog.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
dialog.cancel();
}
});
//Display AlertDialog when tapped
dialog.show();
return true;
}
public void addOverlay(OverlayItem overlay) {
mapOverlays.add(overlay);
this.populate();
}
}