Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Receive dispatchEvent from lua to native layer
Started by jazzalar Jul 24 2018 12:04 PM

3 replies to this topic
android corona dispatch event
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

jazzalar

[GLOBAL: userInfoPane.html]
jazzalar
  • Observer

  • 3 posts
  • Corona SDK

I've recently updated the Corona SDK I was using and I'm unsure how I go about listening for a dispatch event in the native android layer. I have this in my scene.lua
 

local gameOverEvent = { name = "coronaView", message = "gameOver" }
      
Runtime:dispatchEvent(gameOverEvent)

and this in android 

 

@Override
    public Object onReceivedCoronaEvent(CoronaView coronaView, Hashtable<Object, Object> hashtable) {
        if (hashtable.get("name").equals("coronaView")) {
            if (eventListener != null) {
                CoronaEvent event = new CoronaEvent(hashtable);

                if ("gameOver".equals(event.getMessage())) {
                    eventListener.gameOver();
                } 
        
        return null;
    }

This used to work but it looks like I don't have access to the CoronaView anymore. How do you go about listening for the event in the more recent Corona SDK?

Thanks



[TOPIC: post.html]
#2

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 24,331 posts
  • Corona Staff

This appears to be the same question asked here, but with a different account:
 

https://forums.coronalabs.com/topic/73407-listening-for-a-dispatch-event-in-the-native-android-layer/

 

Which account should we respond to?

 

Rob


  • j.mclaughlin likes this

[TOPIC: post.html]
#3

jazzalar

[GLOBAL: userInfoPane.html]
jazzalar
  • Observer

  • 3 posts
  • Corona SDK

This appears to be the same question asked here, but with a different account:
 

https://forums.coronalabs.com/topic/73407-listening-for-a-dispatch-event-in-the-native-android-layer/

 

Which account should we respond to?

 

Rob

Hi Rob, thanks for the quick reply. Please respond to this thread. I posted twice as I thought something had gone wrong with my first question.

Thanks



[TOPIC: post.html]
#4

jazzalar

[GLOBAL: userInfoPane.html]
jazzalar
  • Observer

  • 3 posts
  • Corona SDK

Sorry for the bump. Is anyone able to help me? Thanks


[topic_controls]
[/topic_controls]

Also tagged with one or more of these keywords: android, corona, dispatch, event