AsyncTask has nothing to do with implementing a listener.
Here's a listener:
public interface TheListener {
public void somethingHappened();
}
Call it however you want. For example, here's a class doing something like View:
public class Something {
private TheListener mTheListener;
public void setTheListener(TheListener listen) {
mTheListener = listen;
}
private void reportSomethingChanged() {
if (mTheListener != null) {
mTheListener.somethingHappened();
}
}
}
You can make this as complicated as you want. For example, instead of a single listener pointer you could have an ArrayList to allow multiple listeners to be registered.
Calling this from native code also has nothing to do with implementing a listener interface. You just need to learn about JNI to learn how native code can interact with Java language code.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…