Android-version-dependent compilation -



Android-version-dependent compilation -

is there kind of conditional compiling android? trying utilize android.webkit.webview.onpause(), while still supporting android api 8.

i tried solutions suggested fiddler , andrey voitenkov @ 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 still prevented compiling/running app:

"the method onpause() undefined type webview"

and

"your project contains error(s), please prepare them before running application."

am doing wrong, or not possible this?

your code looks fine, checks minimal sdk version before using feature available version on. if run app on android device version lower api 11, code not executed. if run on android device api 11 or higher, executed.

so means, app should compiled against @ to the lowest degree api 11, because contains feature introduced in api 11. depending on version run on, feature enabled or not.

to this, adjust androidmanifest.xml :

<uses-sdk android:minsdkversion="8" android:targetsdkversion="11" />

this build android app against api 11, still allows used on android device running api 8 or later.

android conditional-compilation android-version build-time

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -