def value(startH,startM,stopH,stopM):
def job():
do job
def job1():
do another job
start_time = "{0:02d}:{1:02d}".format(startH, startM)
stop_time = "{0:02d}:{1:02d}".format(stopH, stopM)
schedule.every().day.at(start_time).do(job)
schedule.every().day.at(stop_time).do(job1)
while True:
schedule.run_pending()
time.sleep(1)
ここでstartH、startM、stopH、stopMは、開始時、開始時、停止時、停止時を意味します。アンドロイドを介してユーザによって与えられた入力である。このコードは実行されます。それはoncesを実行し、それから実行を続けます。ここに訴訟があります。私は再び時間を入力したい場合。それは受け入れられません。ループがまだ実行されている間にユーザーからの入力を受け入れるにはどうすればいいですか?最初のタスクがライトをオンにしてから2番目のタスクがライトをオフにしていると言うことができます。したがって、第2のタスクが完了したとき。それは完全なものとみなされます。ブレーク、リターンを使ってみました。それは仮定されているように動作しません。whileループを実行してもユーザー入力を受け入れる方法はありますか?
public void publish(int startH,int startM, int stopH, int stopM)
{
JSONObject js = new JSONObject();
try {
js.put("START_HOUR", startH);
js.put("START_MINUTE", startM);
js.put("STOP_HOUR", stopH);
js.put("STOP_MINUTE", stopM);
}
public void setTime(View view)
{
int storeStartHour = Integer.parseInt(startHrs.getText().toString());
int storeStartMinutes = Integer.parseInt(startMinutes.getText().toString());
int storeStopHour = Integer.parseInt(stopHrs.getText().toString());
int storeStopMinutes = Integer.parseInt(stopMinutes.getText().toString());
publish(storeStartHour, storeStartMinutes, storeStopHour, storeStopMinutes);
}
スレッドを使用する、Luke – Sergius
スレッドなどと呼ばれています。それまたは非同期/非ブロッキングコード。私はここにあなたのためにそれを置くだろうかわからないユーザーの入力を参照してください。 – Torxed
@Torxedアンドロイドからの入力はstartHに格納され、startHはstartHでstartMはstopHとstopMの開始分などです。一度設定することができます。その後、私はもう一度設定することはできません... – sam