I'm developing a Cordova plugin on Android, but with Cordova Android new version (v 4.0.0) some methods I'm using have changed.
In my plugin.java I am using (on cordova android <= 3.7.1) :
//Adding listener on scroll when my plugin is initiated
webView.getViewTreeObserver().addOnScrollChangedListener(this);
//Then later
@Override
public void onScrollChanged() {
//custom actions when scrolling
}
Seem that now with cordova-android V.4.0.0, the way to access webView has changed
"onScrollChanged" message removed. Use view.getViewTreeObserver().addOnScrollChangedListener(...) instead
So now I have to do it this way with cordova-android 4.0.0 :
webView.getView().getViewTreeObserver().addOnScrollChangedListener(this);
Since my plugin has to be compatible with cordova-android < 4.0.0 and cordova-android >= 4.0.0, I was looking for a simple way to check cordova-android current version in my plugin.java to do one or the other method, but so far I haven't found how to do it...
So is there a public method to access corodova-android from an android plugin ? Have I missed an already common method to all cordova-android version do to what I want ?
Thank you all
Solution found for this problem : use of Reflection