Is there any kind of conditional compiling for Android? I am trying to use android.webkit.WebView.onPause(), while still also supporting Android API 8.
I tried the solutions suggested by Fiddler and Andrey Voitenkov at Conditional compiling in Android? :
public void pause()
{
int version = android.os.Build.VERSION.SDK_INT;
if(version >= 11)
{
webViewOnPause(_webView);
}
super.onPause();
}
@TargetApi(11)
void webViewOnPause(final android.webkit.WebView webview)
{
new Runnable() {
public void run() {
new PauseStuffAvailableOnHC(webview);
}
}.run();
}
class PauseStuffAvailableOnHC
{
@TargetApi(11)
public PauseStuffAvailableOnHC(android.webkit.WebView webview)
{
webview.onPause();
}
}
...but I am still prevented from compiling/running the app:
"The method onPause() is undefined for the type WebView"
and
"Your project contains error(s), please fix them before running your application."
Am I doing something wrong, or is it simply not possible to do this?