You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cordova.apache.org by Braden Shepherdson <br...@chromium.org> on 2012/08/29 21:10:48 UTC

[DISCUSS][Android] Polling plugins onNewIntent

I'm working on the status bar notification plugin for Android, hoping to
add support for onclick as in the W3C spec.

There are basically three approaches to capturing the Intent when the
notification is clicked:
1. Create a new Activity that causes the onclick to be called and then
hands off to the main Cordova Activity.
2. Have the user of the plugin add onNewIntent() to the root of the app,
with code provided in the plugin's documentation.
3. Do something similar to the plugin polling when the top-level URL
changes.

I've been investigating (1), but it requires adding an Activity to the app
manifest. (2) sucks in several ways. (3) appeals to me the most, but
requires that polling of plugins. It will only be active when something is
actually sending new Intents to the app, which currently doesn't happen at
all. It would also enable other apps to call into Cordova apps and have
plugins capture those events. (Share, etc.)

Thoughts? I'm mostly glad I can actually support onclick.

Braden

Re: [DISCUSS][Android] Polling plugins onNewIntent

Posted by Andrew Grieve <ag...@chromium.org>.
Yeah, sendJavascript should eval your JS. if you suspect alert() to be the
problem, try out a console.log() since those get piped to ADB.


On Wed, Aug 29, 2012 at 5:58 PM, Filip Maj <fi...@adobe.com> wrote:

> Hmm that sounds iffy. Perhaps the app isn't "live" when the plugin gets
> invoked via intent?
>
> I would post an issue to JIRA and provide a sample app to repro the case.
>
> On 8/29/12 2:52 PM, "Braden Shepherdson" <br...@chromium.org> wrote:
>
> >Hm, I'm trying to use sendJavascript in onNewIntent (which is getting
> >called) to call a global function (or testing with alert()) and it's not
> >getting called. I can't find any examples of sendJavascript being used in
> >plugins for Android. Am I doing it wrong? How should I call Javascript
> >from
> >native?
> >
> >
> >On Wed, Aug 29, 2012 at 5:20 PM, Braden Shepherdson
> ><br...@chromium.org>wrote:
> >
> >> I don't know about the Message API, but it certainly has something to do
> >> with the code a function below your link [1]: We capture onNewIntent and
> >> call that on plugins. >_>
> >>
> >> So I'll use that, and it looks like it will work great. Thanks for the
> >> link!
> >>
> >> Braden
> >>
> >>
> >> On Wed, Aug 29, 2012 at 4:14 PM, Filip Maj <fi...@adobe.com> wrote:
> >>
> >>> Is this at all related to the high-level / general purpose "Message"
> >>>api
> >>> we have in plugins [1] [2]? Could that be used instead?
> >>>
> >>> [1]
> >>>
> >>>
> >>>
> https://github.com/apache/incubator-cordova-android/blob/master/framewor
> >>>k/s
> >>>
> >>>rc/org/apache/cordova/api/PluginManager.java#L318<
> https://github.com/apa
> >>>che/incubator-cordova-android/blob/master/framework/src/org/apache/cordo
> >>>va/api/PluginManager.java#L318>
> >>> [2]
> >>>
> >>>
> >>>
> https://github.com/apache/incubator-cordova-android/blob/master/framewor
> >>>k/s
> >>>
> >>>rc/org/apache/cordova/api/Plugin.java#L114<
> https://github.com/apache/inc
> >>>ubator-cordova-android/blob/master/framework/src/org/apache/cordova/api/
> >>>Plugin.java#L114>
> >>>
> >>> On 8/29/12 12:10 PM, "Braden Shepherdson" <br...@chromium.org> wrote:
> >>>
> >>> >I'm working on the status bar notification plugin for Android, hoping
> >>>to
> >>> >add support for onclick as in the W3C spec.
> >>> >
> >>> >There are basically three approaches to capturing the Intent when the
> >>> >notification is clicked:
> >>> >1. Create a new Activity that causes the onclick to be called and then
> >>> >hands off to the main Cordova Activity.
> >>> >2. Have the user of the plugin add onNewIntent() to the root of the
> >>>app,
> >>> >with code provided in the plugin's documentation.
> >>> >3. Do something similar to the plugin polling when the top-level URL
> >>> >changes.
> >>> >
> >>> >I've been investigating (1), but it requires adding an Activity to the
> >>> app
> >>> >manifest. (2) sucks in several ways. (3) appeals to me the most, but
> >>> >requires that polling of plugins. It will only be active when
> >>>something
> >>> is
> >>> >actually sending new Intents to the app, which currently doesn't
> >>>happen
> >>> at
> >>> >all. It would also enable other apps to call into Cordova apps and
> >>>have
> >>> >plugins capture those events. (Share, etc.)
> >>> >
> >>> >Thoughts? I'm mostly glad I can actually support onclick.
> >>> >
> >>> >Braden
> >>>
> >>>
> >>
>
>

Re: [DISCUSS][Android] Polling plugins onNewIntent

Posted by Filip Maj <fi...@adobe.com>.
Hmm that sounds iffy. Perhaps the app isn't "live" when the plugin gets
invoked via intent?

I would post an issue to JIRA and provide a sample app to repro the case.

On 8/29/12 2:52 PM, "Braden Shepherdson" <br...@chromium.org> wrote:

>Hm, I'm trying to use sendJavascript in onNewIntent (which is getting
>called) to call a global function (or testing with alert()) and it's not
>getting called. I can't find any examples of sendJavascript being used in
>plugins for Android. Am I doing it wrong? How should I call Javascript
>from
>native?
>
>
>On Wed, Aug 29, 2012 at 5:20 PM, Braden Shepherdson
><br...@chromium.org>wrote:
>
>> I don't know about the Message API, but it certainly has something to do
>> with the code a function below your link [1]: We capture onNewIntent and
>> call that on plugins. >_>
>>
>> So I'll use that, and it looks like it will work great. Thanks for the
>> link!
>>
>> Braden
>>
>>
>> On Wed, Aug 29, 2012 at 4:14 PM, Filip Maj <fi...@adobe.com> wrote:
>>
>>> Is this at all related to the high-level / general purpose "Message"
>>>api
>>> we have in plugins [1] [2]? Could that be used instead?
>>>
>>> [1]
>>>
>>> 
>>>https://github.com/apache/incubator-cordova-android/blob/master/framewor
>>>k/s
>>> 
>>>rc/org/apache/cordova/api/PluginManager.java#L318<https://github.com/apa
>>>che/incubator-cordova-android/blob/master/framework/src/org/apache/cordo
>>>va/api/PluginManager.java#L318>
>>> [2]
>>>
>>> 
>>>https://github.com/apache/incubator-cordova-android/blob/master/framewor
>>>k/s
>>> 
>>>rc/org/apache/cordova/api/Plugin.java#L114<https://github.com/apache/inc
>>>ubator-cordova-android/blob/master/framework/src/org/apache/cordova/api/
>>>Plugin.java#L114>
>>>
>>> On 8/29/12 12:10 PM, "Braden Shepherdson" <br...@chromium.org> wrote:
>>>
>>> >I'm working on the status bar notification plugin for Android, hoping
>>>to
>>> >add support for onclick as in the W3C spec.
>>> >
>>> >There are basically three approaches to capturing the Intent when the
>>> >notification is clicked:
>>> >1. Create a new Activity that causes the onclick to be called and then
>>> >hands off to the main Cordova Activity.
>>> >2. Have the user of the plugin add onNewIntent() to the root of the
>>>app,
>>> >with code provided in the plugin's documentation.
>>> >3. Do something similar to the plugin polling when the top-level URL
>>> >changes.
>>> >
>>> >I've been investigating (1), but it requires adding an Activity to the
>>> app
>>> >manifest. (2) sucks in several ways. (3) appeals to me the most, but
>>> >requires that polling of plugins. It will only be active when
>>>something
>>> is
>>> >actually sending new Intents to the app, which currently doesn't
>>>happen
>>> at
>>> >all. It would also enable other apps to call into Cordova apps and
>>>have
>>> >plugins capture those events. (Share, etc.)
>>> >
>>> >Thoughts? I'm mostly glad I can actually support onclick.
>>> >
>>> >Braden
>>>
>>>
>>


Re: [DISCUSS][Android] Polling plugins onNewIntent

Posted by Braden Shepherdson <br...@chromium.org>.
Hm, I'm trying to use sendJavascript in onNewIntent (which is getting
called) to call a global function (or testing with alert()) and it's not
getting called. I can't find any examples of sendJavascript being used in
plugins for Android. Am I doing it wrong? How should I call Javascript from
native?


On Wed, Aug 29, 2012 at 5:20 PM, Braden Shepherdson <br...@chromium.org>wrote:

> I don't know about the Message API, but it certainly has something to do
> with the code a function below your link [1]: We capture onNewIntent and
> call that on plugins. >_>
>
> So I'll use that, and it looks like it will work great. Thanks for the
> link!
>
> Braden
>
>
> On Wed, Aug 29, 2012 at 4:14 PM, Filip Maj <fi...@adobe.com> wrote:
>
>> Is this at all related to the high-level / general purpose "Message" api
>> we have in plugins [1] [2]? Could that be used instead?
>>
>> [1]
>>
>> https://github.com/apache/incubator-cordova-android/blob/master/framework/s
>> rc/org/apache/cordova/api/PluginManager.java#L318<https://github.com/apache/incubator-cordova-android/blob/master/framework/src/org/apache/cordova/api/PluginManager.java#L318>
>> [2]
>>
>> https://github.com/apache/incubator-cordova-android/blob/master/framework/s
>> rc/org/apache/cordova/api/Plugin.java#L114<https://github.com/apache/incubator-cordova-android/blob/master/framework/src/org/apache/cordova/api/Plugin.java#L114>
>>
>> On 8/29/12 12:10 PM, "Braden Shepherdson" <br...@chromium.org> wrote:
>>
>> >I'm working on the status bar notification plugin for Android, hoping to
>> >add support for onclick as in the W3C spec.
>> >
>> >There are basically three approaches to capturing the Intent when the
>> >notification is clicked:
>> >1. Create a new Activity that causes the onclick to be called and then
>> >hands off to the main Cordova Activity.
>> >2. Have the user of the plugin add onNewIntent() to the root of the app,
>> >with code provided in the plugin's documentation.
>> >3. Do something similar to the plugin polling when the top-level URL
>> >changes.
>> >
>> >I've been investigating (1), but it requires adding an Activity to the
>> app
>> >manifest. (2) sucks in several ways. (3) appeals to me the most, but
>> >requires that polling of plugins. It will only be active when something
>> is
>> >actually sending new Intents to the app, which currently doesn't happen
>> at
>> >all. It would also enable other apps to call into Cordova apps and have
>> >plugins capture those events. (Share, etc.)
>> >
>> >Thoughts? I'm mostly glad I can actually support onclick.
>> >
>> >Braden
>>
>>
>

Re: [DISCUSS][Android] Polling plugins onNewIntent

Posted by Braden Shepherdson <br...@chromium.org>.
I don't know about the Message API, but it certainly has something to do
with the code a function below your link [1]: We capture onNewIntent and
call that on plugins. >_>

So I'll use that, and it looks like it will work great. Thanks for the link!

Braden


On Wed, Aug 29, 2012 at 4:14 PM, Filip Maj <fi...@adobe.com> wrote:

> Is this at all related to the high-level / general purpose "Message" api
> we have in plugins [1] [2]? Could that be used instead?
>
> [1]
> https://github.com/apache/incubator-cordova-android/blob/master/framework/s
> rc/org/apache/cordova/api/PluginManager.java#L318
> [2]
> https://github.com/apache/incubator-cordova-android/blob/master/framework/s
> rc/org/apache/cordova/api/Plugin.java#L114
>
> On 8/29/12 12:10 PM, "Braden Shepherdson" <br...@chromium.org> wrote:
>
> >I'm working on the status bar notification plugin for Android, hoping to
> >add support for onclick as in the W3C spec.
> >
> >There are basically three approaches to capturing the Intent when the
> >notification is clicked:
> >1. Create a new Activity that causes the onclick to be called and then
> >hands off to the main Cordova Activity.
> >2. Have the user of the plugin add onNewIntent() to the root of the app,
> >with code provided in the plugin's documentation.
> >3. Do something similar to the plugin polling when the top-level URL
> >changes.
> >
> >I've been investigating (1), but it requires adding an Activity to the app
> >manifest. (2) sucks in several ways. (3) appeals to me the most, but
> >requires that polling of plugins. It will only be active when something is
> >actually sending new Intents to the app, which currently doesn't happen at
> >all. It would also enable other apps to call into Cordova apps and have
> >plugins capture those events. (Share, etc.)
> >
> >Thoughts? I'm mostly glad I can actually support onclick.
> >
> >Braden
>
>

Re: [DISCUSS][Android] Polling plugins onNewIntent

Posted by Filip Maj <fi...@adobe.com>.
Is this at all related to the high-level / general purpose "Message" api
we have in plugins [1] [2]? Could that be used instead?

[1] 
https://github.com/apache/incubator-cordova-android/blob/master/framework/s
rc/org/apache/cordova/api/PluginManager.java#L318
[2] 
https://github.com/apache/incubator-cordova-android/blob/master/framework/s
rc/org/apache/cordova/api/Plugin.java#L114

On 8/29/12 12:10 PM, "Braden Shepherdson" <br...@chromium.org> wrote:

>I'm working on the status bar notification plugin for Android, hoping to
>add support for onclick as in the W3C spec.
>
>There are basically three approaches to capturing the Intent when the
>notification is clicked:
>1. Create a new Activity that causes the onclick to be called and then
>hands off to the main Cordova Activity.
>2. Have the user of the plugin add onNewIntent() to the root of the app,
>with code provided in the plugin's documentation.
>3. Do something similar to the plugin polling when the top-level URL
>changes.
>
>I've been investigating (1), but it requires adding an Activity to the app
>manifest. (2) sucks in several ways. (3) appeals to me the most, but
>requires that polling of plugins. It will only be active when something is
>actually sending new Intents to the app, which currently doesn't happen at
>all. It would also enable other apps to call into Cordova apps and have
>plugins capture those events. (Share, etc.)
>
>Thoughts? I'm mostly glad I can actually support onclick.
>
>Braden