我的問題是,如果地點事件監聽器(內部方法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 –