Enable WiFi when a specific application needs it, then disable after N minutes
Good. In this case you may try Tasker from App Store (However there are free trail available). Set your profile that triggers when the Specific App (Ankidroid) is Opened, and write a simple task

Proile:
1. App-> Ankidroid

Task:
1. Enable WIFI
2. Wait N Seconds
3. Disable WIFI

Tasker need some learning curve though, but it is very powerful and you can automate anything in your phone!