Aside: CordovaWebView allows you to use the PhoneGap/Cordova component in a larger Android application. Extending the DroidGap class is no longer necessary if you are providing your own Activity that embeds a CordovaWebView. However, you can continue to extend the DroidGap class to give yourself a leg up.
As a result of removing those methods Plugins who were dependent on them being implemented by CordovaInterface ctx member of the Plugin class were left wondering what do I need to do to get my Plugin to compile with PhoneGap 1.9.0.
Well we are sorry for that, it could have and should have been handled better. When PhoneGap 2.0.0 drops we are changing ctx from a CordovaInterface to a LegacyContext class. LegacyContext is a new class that we've introduced that bridges the old CordovaInterface API to the new CordovaInterface API. This means that any Plugin that worked in 1.8.1 should continue to work in 2.0.0 without modification.
This doesn't mean that LegacyContext will be around forever. In fact the class is already deprecated. We will be publishing an Plugin upgrade guide to help developers update their Plugins to the new API. I'll also be going through my plugins (ChildBrowser, TTS, VideoPlayer) and updating the repo to have 1.8.1 and 1.9.0 versions of the Plugins for people to reference. The ctx member from the Plugin class will be going away in a couple of point releases as it has been replaced by a cordova member which is an instance of CordovaInterface.
For those of you who want to get a jump start on updating your plugins here is a brief guide.
- ctx.getContext() replaced with cordova.getContext()
- ctx.startActivity() replaced with cordova.getActivity().startActivity()
- ctx.getSystemService() replaced with cordova.getActivity().getSystemService()
- ctx.getAssets() replaced with cordova.getActivity().getAssets()
- ctx.runOnUiThread() replaced with cordova.getActivity().runOnUiThread()
- ctx.getApplicationContext() replaced with cordova.getActivity().getApplicationContext()
- ctx.getPackageManager() replaced with cordova.getActivity().getPackageManager()
- ctx.getSharedPreferences() replaced with cordova.getActivity().getSharedPreferences()
- ctx.unregisterActivity() replaced with cordova.getActivity().unregisterActivity()
- ctx.getResources() replaced with cordova.getActivity().getResources()
- import com.phonegap.api.* replaced with import org.apache.cordova.api.*