Return-Path: X-Original-To: apmail-incubator-callback-dev-archive@minotaur.apache.org Delivered-To: apmail-incubator-callback-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C7E359347 for ; Fri, 8 Jun 2012 19:58:16 +0000 (UTC) Received: (qmail 54791 invoked by uid 500); 8 Jun 2012 19:58:16 -0000 Delivered-To: apmail-incubator-callback-dev-archive@incubator.apache.org Received: (qmail 54764 invoked by uid 500); 8 Jun 2012 19:58:16 -0000 Mailing-List: contact callback-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: callback-dev@incubator.apache.org Delivered-To: mailing list callback-dev@incubator.apache.org Received: (qmail 54756 invoked by uid 99); 8 Jun 2012 19:58:16 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 Jun 2012 19:58:16 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of bowserj@gmail.com designates 74.125.82.175 as permitted sender) Received: from [74.125.82.175] (HELO mail-we0-f175.google.com) (74.125.82.175) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 Jun 2012 19:58:10 +0000 Received: by werg55 with SMTP id g55so840785wer.6 for ; Fri, 08 Jun 2012 12:57:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=uQ/l9sgAW8sk8KP437c4DiGVk3JP/aHtpXqiJ2QcvV0=; b=mjhIsK8g0v0INSA9/IEAegO1mGvJ9igzTfTlW78ztOKnzbWiQKw3o/gIVloQ7wi3lO +48FkykAL91PVOtjRidA4yKurkQgzbPqpBbr7UeAuD5QQSQKIb9BqiuGv1qffQcqZJbD kZPpQhuo26iA1a8istgrSn6HZNHW++RDUvzgInIi5lZh7n0PQZwfm9RhtTdn5Jkd1qvO v7zCNCjtmRnPzFbxfm0URj8OyLv0eJiowQRmmhch7VlWL2Utu25jgnYxr2L4aq7WYnmC 8UKUXG6rf0N7euJmhnFvyeusWRDJt6X3XeB/BCKPjBb2YQPiiVAz4aBNkNspvNusEAXK UuUg== MIME-Version: 1.0 Received: by 10.180.8.69 with SMTP id p5mr3028487wia.17.1339185470279; Fri, 08 Jun 2012 12:57:50 -0700 (PDT) Received: by 10.223.47.135 with HTTP; Fri, 8 Jun 2012 12:57:50 -0700 (PDT) In-Reply-To: References: Date: Fri, 8 Jun 2012 12:57:50 -0700 Message-ID: Subject: Re: Android devs From: Joe Bowser To: callback-dev@incubator.apache.org Content-Type: multipart/alternative; boundary=f46d044283b63e908304c1fb6ad4 --f46d044283b63e908304c1fb6ad4 Content-Type: text/plain; charset=ISO-8859-1 Those will both fail in the most recent version of Cordova that just arrived if the CordovaInterface is not also an Activity. The reason for this is because ctx is not a context, but is instead a CordovaInterface. Instead to get the activity, you need to do this: ctx.getActivity(); And to get and set the intent, you need to do this: ctx.getActivity().getIntent(); ctx.getActivity().setIntent(); With the new change, CordovaInterface can be any class as long as it implements the methods. I don't see any way that it can NOT be an Activity, but this way, we avoid casting. On Fri, Jun 8, 2012 at 12:41 PM, Don Coleman wrote: > 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" 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 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 > > >> 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 > > >> > 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 > > 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 > > >> > >> 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 > > >> > >> > > > >> > >> > > >> > > > >> > > > > > > > > > --f46d044283b63e908304c1fb6ad4--