incubator-callback-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Don Coleman <don.cole...@gmail.com>
Subject Re: Android devs
Date Fri, 08 Jun 2012 19:41:16 GMT
I use Activity and Intent in the NFC plugin.  When I upgraded the plugin
for cordova 1.6, I need to cast ctx to Activity everywhere.

I added getActivity() and getIntent() make things a bit clearer.
https://github.com/chariotsolutions/phonegap-nfc/blob/master/android/src/com/chariotsolutions/nfc/plugin/NfcPlugin.java#L391

Are there cases where this cast might fail?


On Jun 8, 2012 2:49 PM, "Joe Bowser" <bowserj@gmail.com> wrote:

> This gets back to ctx vs ctx.getActivity/ctx.getContext.
>
> Earlier on when working on CordovaWebView, I changed the plugins to require
> a context instead of a CordovaInterface because Activities are Contexts,
> and we can't guarantee that users are going to be using DroidGap with the
> new CordovaWebView change.  This was changed so all plugins have to use a
> CordovaInterface.  However, since we can't guarantee that a
> CordovaInterface is an Activity, (because someone needs it to work with
> MapActivity), this change got removed because casting objects is frowned
> upon like using duct tape to patch a hole in your boat.
>
> This is probably the biggest stumbling block with plugins, since you need
> the context to start activities, create intents and for other interaction
> with Android.  We should settle with a solid way to do this so that plugin
> developers know what's going on.
>
> BTW: Are there any non-Adobe or non-IBM Android peeps on here who can speak
> up? It'd be good to hear from someone who hasn't re-written this part of
> the code yet.
>
> Joe
>
> On Fri, Jun 8, 2012 at 11:40 AM, Joe Bowser <bowserj@gmail.com> wrote:
>
> > No, it means that ctx.getContext() will have to be change to
> > ctx.getActivity(), since Activities are Contexts.
> > http://developer.android.com/reference/android/app/Activity.html
> >
> >
> > On Fri, Jun 8, 2012 at 11:31 AM, Simon MacDonald <
> > simon.macdonald@gmail.com> wrote:
> >
> >> Okay, I'll pull it out. It just means all those folks we told to change:
> >> ctx
> >>
> >> to: ctx.getContext() in 1.5+
> >>
> >> will now need to make it: ctx.getActivity().getContext() in 1.9+.
> >>
> >> Simon Mac Donald
> >> http://hi.im/simonmacdonald
> >>
> >>
> >> On Fri, Jun 8, 2012 at 2:27 PM, Bryce Curtis <curtis.bryce@gmail.com>
> >> wrote:
> >>
> >> > getContext was not added to interface since it is available from
> >> > getActivity().getContext().
> >> >
> >> > On Fri, Jun 8, 2012 at 1:24 PM, Simon MacDonald
> >> > <simon.macdonald@gmail.com> wrote:
> >> > > Yeah, the video player plugin uses it to start playing video.
> >> > >
> >> > > Simon Mac Donald
> >> > > http://hi.im/simonmacdonald
> >> > >
> >> > >
> >> > > On Fri, Jun 8, 2012 at 2:10 PM, Joe Bowser <bowserj@gmail.com>
> wrote:
> >> > >
> >> > >> Why would you want to start an activity where you wouldn't get
a
> >> result?
> >> > >> Just to put it on the stack?
> >> > >>
> >> > >> On Fri, Jun 8, 2012 at 11:05 AM, Simon MacDonald
> >> > >> <simon.macdonald@gmail.com>wrote:
> >> > >>
> >> > >> > Please take a look at:
> >> > >> >
> >> > >> >
> >> > >> >
> >> > >>
> >> >
> >>
> https://git-wip-us.apache.org/repos/asf?p=incubator-cordova-android.git;a=commit;h=95b48705fea2cac0f2561f84d3f1ecf017357b58
> >> > >> >
> >> > >> > I added getContext and startActivity back into CordovaInterface.
> >> Does
> >> > >> > anyone see any problems with this? I've done it to make life
with
> >> the
> >> > >> > current crop of plugins easier.
> >> > >> >
> >> > >> > Simon Mac Donald
> >> > >> > http://hi.im/simonmacdonald
> >> > >> >
> >> > >>
> >> >
> >>
> >
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message