1

I need my APP to hide virtual keys on Samsung 9250/Galaxy Nexus by invoking 3.0(level 11) API View.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION), but I still need my APK runnable on device with Android v2.2/2.3/2.31.

Maybe I shall use

int SDK_INT = android.os.Build.VERSION.SDK_INT;
if(SDK_INT >= 11) {
        getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
}else{
        //do nothing
}

But what shall I do in manifest file and which library shall I use to build project?

Thanks.

Bob
  • 22,810
  • 38
  • 143
  • 225
Archy
  • 408
  • 5
  • 12

2 Answers2

2

Thank you for your help.

Reflection or wrapper classes seems too complex.

I just use 4.0 lib to build, setting

<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="15"/>

and use

if(Build.VERSION.SDK_INT >= HIDENAVIGATION_MIN_SDK)  
   getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);

It seems OK on both 4.x and 2.2/2.3 platform.

But I meet the problem on Samsung Nexus(9250), even if getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE) is invoked, I can get 1196*720, but I need 1280*720 actually.

Get the real screen resolution on Ice Cream Sandwich

Is there any other API we can make use of ?

Thanks.

Community
  • 1
  • 1
Archy
  • 408
  • 5
  • 12
1

There are certainly a couple of options for supporting multiple versions of Android which don't utilize the same API's, one way is reflection and another is using wrapper classes. Supporting multiple platform versions is a common thing to do and there is a fairly comprehensive article on both here.

To appropriately set the AndroidManifest.xml you would need to add the following tag:

<uses-sdk
    android:minSdkVersion="4"
    android:targetSdkVersion="10"
    android:maxSdkVersion="10" />

Where the minimum SDK is the lowest that your application supports and the target is the highest that your application has been tested on that you know works. Maximum SDK is optional if you REALLY do not want your application used above a certain API level (perhaps you use deprecated methods that are not supported in newer versions).

Edit: As far as which library to use, pick the lowest version that gives you all the functionality you need. If you need methods only available in API level 11, then use that. If it ends up being higher than your "minimum supported version," just remember to test the earlier versions very carefully.

happydude
  • 3,869
  • 2
  • 23
  • 41