Ich habe eine ziemlich einfache App, die ich in Clojure geschrieben habe und möchte regelmäßig eine seiner Funktionen automatisch ausführen. Ich versuche, Android AlarmManager
zu verwenden, um die Aufgabe zu planen. Das ist, was ich habe, so weit:Erstellen eines Android-Dienstes in Clojure
Android in der Dokumentation Referenz enter link description here
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();
}
}
}
Meine eigenen Fortschritt in Clojure:
(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"))
Ich glaube, ich bin Missverständnis etwas subtiler; nach Auswertung des ersten Sexp ist das Symbol adamdavislee.mpd.Service
ungebunden und das Symbol superIntentService
auch nicht.
Vielen Dank; Ich komme jetzt näher, insbesondere half es zu erkennen, dass 'superIntentService' als Methode und nicht als normales Symbol dargestellt wurde. –