Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><a href="http://docs.phonegap.com/en/2.0.0/guide_plugin-development_android_index.md.html#Developing%20a%20Plugin%20on%20Android" rel="nofollow">http://docs.phonegap.com/en/2.0.0/guide_plugin-development_android_index.md.html#Developing%20a%20Plugin%20on%20Android</a></p> <p>After checking this, i found:</p> <blockquote> <p>Common Pitfalls</p> <p>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.</p> <p>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.</p> <p>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.</p> </blockquote> <p>Here is my fix: </p> <p>in DatePickerPlugin.java</p> <pre><code>import android.content.Context; .... public synchronized void show(final JSONArray data, final String callBackId) { final DatePickerPlugin datePickerPlugin = this; final DroidGap currentCtx = (DroidGap) ctx.getContext(); final Calendar c = Calendar.getInstance(); ..... </code></pre> <p>replace line:</p> <pre><code>final DroidGap currentCtx = (DroidGap) ctx.getContext(); </code></pre> <p>by: </p> <pre><code>final Context currentCtx = cordova.getActivity(); </code></pre> <p>Find:</p> <pre><code>ctx.runOnUiThread(runnable); </code></pre> <p>replace by:</p> <pre><code>cordova.getActivity().runOnUiThread(runnable); </code></pre> <p>This is working fine in my emulator 4.0.3 with phonegap 2.0</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload