I am pretty sure this question has been asked before, but I could not find it anywhere, so please don't bite.
I am writing an android app, that needs to communicate with nearby devices and I want to used WifiDirect API if two devices that have it happen to be nearby.
But if that's not the case application can still work and it will use other less effective ways to communicate between participating devices (like Wifi Access Point sharing).
I also want this app to be possible to run on older devices like android 2.2 which does not have WifiDirect API at all (>=4.0 I think).
So is there anyway to make my app optionally use new API, but not necessarily in case of older phones?
so please don't bite
Can we at least gnaw a little? Just a nibble?
:-)
So is there anyway to make my app optionally use new API, but not necessarily in case of older phones?
You can wrap your references to new classes/methods in Java version guard blocks:
if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
// do stuff with WifiP2pManager
}
// optional else block for workaround for older devices
There may be other particulars for WiFiDirect, which I haven't used yet, but that's the basic step.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With