0

I'm developing an app that uses wi-fi direct module. As you all know it's not available before Android 4.0, but I want to mantain compatibility without wi-fi direct.

The problem is I'm using instance variables from classes like Channel or WifiP2pManager. Of course on prior versions to ICS they'll not be available. I was just following the Android official developer guide, so It seemed that I did nothing wrong.

Any ideas of how can I solve this?

Thanks!

Javier Manzano
  • 4,761
  • 16
  • 56
  • 86

3 Answers3

1
if(Build.VERSION_CODES < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
    // compat code here
} else {
  // normal code here
}
Fabian Knapp
  • 1,342
  • 13
  • 27
0

Make your code conditional, like

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES. ICE_CREAM_SANDWICH ) {

  // something

}

or set minSdk version in your manifest

android:minSdkVersion="14"

or, if you need so, split your apps into separate modules, make core not requiring API14 but trying to use wifi-direct module. And wifi-direct module would require API14 so user with proper device would be able to install both, while others just the core.

Marcin Orlowski
  • 72,056
  • 11
  • 123
  • 141
0

It was not a problem with this. It was a problem with Roboguice =)

I've just opened an issue. Just if someone wants to try it =)

http://code.google.com/p/roboguice/issues/detail?id=226&thanks=226&ts=1353421889

Javier Manzano
  • 4,761
  • 16
  • 56
  • 86