How do I get keyboard to disappear after native.showpop ("mail" ....) on Android?

I’m successfully creating a message, and invoking mail via native.showpopup (“mail”),

but on Android when I tap ‘send’ in the mail popup, the keyboard is left visible when I “return” to my app.

(Yes, mail is sent ok)

On iPhone, the keyboard disappears, as it should.

I can’t test this on the simulator (Mac), apparently it doesn’t implement native.showpop for “mail”.

Based on some kludgy debugging, it looks like the listener event isn’t being called on Android *or* iOS!

thanks,

Stan

----------------------------------------------------------------- function bh\_mailit (event) -- Email about 10 lines of text if (event.phase == "ended") then t\_about.text = "creating mail message" -- I see this message on app screen later build\_sabout () -- creates variable "sabout" with about 10 lines of text local options = { to = "sieler@allegro.com", subject = "photolinx info", body = sabout, listener = bh\_mail\_event, } native.showPopup ("mail", options) -- I get a mailer, with the desired content sabout = "" -- release memory end return true end ----------------------------------------------------------------- function bh\_mail\_event (event) print ("bh\_mail\_event: " .. event.phase) -- I don't see this -- note: even when my Android is connected over USB, getting 'print' -- messages fails after about 5 or 6 of them, so I never see this t\_about.text = "bh\_mail\_event: " .. event.phase -- I never see this if event.phase == "ended" then native.setKeyboardFocus (nil) end return true end -- bh\_mail\_event

What events are you getting.  Modify your listener to print them all:

function bh\_mail\_event (event) for k,v in pairs(event) do print( k,v ) print("---------------------", system.getTimer() ) end ...

https://docs.coronalabs.com/api/library/native/setKeyboardFocus.html

 native.setKeyboardFocus( nil )

If you can’t get the listener to fire as needed, use the applicationResume event.

https://docs.coronalabs.com/api/event/system/type.html

local function onSystemEvent( event ) if( event.type == "applicationResume" ) then native.setKeyboardFocus( nil ) end end Runtime:addEventListener( "system", onSystemEvent )

Re: listener

As mentioned in OP, my listener is printing the events … but it’s never getting called on Android or iOS!

Re: app resume event.  Interesting approach, I’ll give it a try.  

thanks!

Stan

What events are you getting.  Modify your listener to print them all:

function bh\_mail\_event (event) for k,v in pairs(event) do print( k,v ) print("---------------------", system.getTimer() ) end ...

https://docs.coronalabs.com/api/library/native/setKeyboardFocus.html

 native.setKeyboardFocus( nil )

If you can’t get the listener to fire as needed, use the applicationResume event.

https://docs.coronalabs.com/api/event/system/type.html

local function onSystemEvent( event ) if( event.type == "applicationResume" ) then native.setKeyboardFocus( nil ) end end Runtime:addEventListener( "system", onSystemEvent )

Re: listener

As mentioned in OP, my listener is printing the events … but it’s never getting called on Android or iOS!

Re: app resume event.  Interesting approach, I’ll give it a try.  

thanks!

Stan