我的问题是,如果地点事件监听器(内部方法changestatus())在发生单击事件后继续执行,或者只调用一次。是继续“运行”的方法
public void onClick(View v) {
if (b1.getText()=="Start" && name!=null) {
b1.setText("Stop");
inte.barstatus();
inte.respond("Trying to find buildings near you");
changestatus();
Toast.makeText(getActivity(), "You have to get close to another building.", Toast.LENGTH_LONG).show();
}
else if (b1.getText()=="Start"){
b1.setText("Stop");
inte.barstatus();
inte.respond("Trying to find buildings near you");
changestatus();
}
else{
b1.setText("Start");
inte.barstatus2();
inte.respond("Press Start button to find buildings near you");
}
}
public void changestatus(){
placeEventListener = new PlaceEventListener() {
@Override
public void onVisitStart(Visit visit) {
super.onVisitStart(visit);
name = visit.getPlace().getName().toString();
switch (name) {
case "test1": {
inte.respond(name.toString());
inte.barstatus2();
ToneGenerator toneG = new ToneGenerator(AudioManager.STREAM_ALARM, 100);
toneG.startTone(ToneGenerator.TONE_CDMA_ALERT_CALL_GUARD, 200);
break;
}
case "test2": {
inte.respond(name.toString());
inte.barstatus2();
ToneGenerator toneY = new ToneGenerator(AudioManager.STREAM_ALARM, 100);
toneY.startTone(ToneGenerator.TONE_CDMA_ALERT_CALL_GUARD, 200);
break;
}
case "Joylamp": {
inte.respond(name.toString());
inte.barstatus2();
ToneGenerator toneT = new ToneGenerator(AudioManager.STREAM_ALARM, 100);
toneT.startTone(ToneGenerator.TONE_CDMA_ALERT_CALL_GUARD, 200);
break;
}
}
}
};
............................................ ............ 我希望你能理解我的问题。 感谢
编辑 我忘了这部分代码,这是内部changestatus()方法:
placeManager = PlaceManager.getInstance();
placeManager.addListener(placeEventListener);
placeManager.startMonitoring();
CommunicationManager.getInstance().startReceivingCommunications();
....看到编辑请...是好的吗? @Guilherme P –