Datepicker Plugin Not Working In Phonegap 2.0
Solution 1:
After checking this, i found:
Common Pitfalls
Plugins have access to a CordovaInterface object. This object has access to the Android Activity that is running the application. This is the Context required to launch a new Android Intent. The CordovaInterface allows plugins to start an Activity for a result, and to set the callback plugin for when the Intent comes back to the application. This is important, since the Intents system is how Android communicates between processes.
Plugins do not have direct access to the Context as they have in the past. The legacy ctx member is deprecated, and will be removed six months after 2.0 is released. All the methods that ctx has exist on the Context, so both getContext() and getActivity() are capable of returning the proper object required.
Avoid calling JavaScript using webView.loadUrl(). The reason we have a callback server is to allow JavaScript execution to be thread-safe, and loadUrl explicitly interrupts the UI thread, and can affect the usability of your plugin.
Here is my fix:
in DatePickerPlugin.java
import android.content.Context;
....
publicsynchronizedvoidshow(final JSONArray data, final String callBackId) {
finalDatePickerPlugindatePickerPlugin=this;
finalDroidGapcurrentCtx= (DroidGap) ctx.getContext();
finalCalendarc= Calendar.getInstance();
.....
replace line:
finalDroidGapcurrentCtx= (DroidGap) ctx.getContext();
by:
finalContextcurrentCtx= cordova.getActivity();
Find:
ctx.runOnUiThread(runnable);
replace by:
cordova.getActivity().runOnUiThread(runnable);
This is working fine in my emulator 4.0.3 with phonegap 2.0
Solution 2:
setting an input field to type "date" brings up the native date picker. super simple way to do it.
Solution 3:
window.plugins
has been removed in PhoneGap 2.0. Try downloading the latest version of the plugin from https://github.com/phonegap/phonegap-plugins.
Post a Comment for "Datepicker Plugin Not Working In Phonegap 2.0"