私はClojureで書いたかなり単純なアプリを持っていて、自動的にその機能の1つを定期的に実行したいと考えています。 AndroidのAlarmManager
を使用してタスクをスケジュールしようとしています。ClojureでAndroidサービスを作成する
Androidのドキュメントを参照enter link description here Clojureの中
public class HelloIntentService extends IntentService {
/**
* A constructor is required, and must call the super IntentService(String)
* constructor with a name for the worker thread.
*/
public HelloIntentService() {
super("HelloIntentService");
}
/**
* The IntentService calls this method from the default worker thread with
* the intent that started the service. When this method returns, IntentService
* stops the service, as appropriate.
*/
@Override
protected void onHandleIntent(Intent intent) {
// Normally we would do some work here, like download a file.
// For our sample, we just sleep for 5 seconds.
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
// Restore interrupt status.
Thread.currentThread().interrupt();
}
}
}
私自身の進歩のために:これは私がこれまで持っているものである
(gen-class
:name adamdavislee.mpd.Service
:extends android.app.IntentService
:exposes-methods {IntentService superIntentService}
:init init
:prefix service)
(defn service-init []
(superIntentService "service")
[[] "service"])
(defn service-onHandleIntent [this i]
(toast "hi"))
私は微妙な何かを誤解していると思います。最初のsexpを評価した後、シンボルadamdavislee.mpd.Service
はアンバインドされておらず、いずれもシンボルsuperIntentService
ではありません。
ありがとうございます。私は近づいています。特に、 'superIntentService'がメソッドとして公開されていて、通常のシンボルではないことに気づいたのです。 –