corona icon indicating copy to clipboard operation
corona copied to clipboard

Android: Update back event handling to work in API level 33

Open appfamily opened this issue 3 years ago • 3 comments

I handle the Android back key in order to prevent kids from accidentally exiting my apps:

local function onKeyEvent(event)
  if (event.keyName == "back" or event.keyName == "deleteBack") and event.phase == "down" then
    -- Misc logic
  end
end
...
if platform == "android" then
  Runtime:addEventListener("key", onKeyEvent)
end

In July I received the e-mail below from Google (screenshot).

As I understand it there is a different API (https://developer.android.com/reference/android/window/OnBackInvokedCallback) that needs to be used, whether or not you want to use fancy gestures or just want to handle the back key yourself just like before.

Links in the mail: https://developer.android.com/reference/android/app/Activity#onBackPressed() https://developer.android.com/guide/navigation/predictive-back-gesture https://codelabs.developers.google.com/handling-gesture-back-navigation#0


image

appfamily avatar Aug 31 '22 14:08 appfamily

So, I finally got to look into it. It seems that changes would come only when we'll target Android 13, api lvl 33. Now we are targeting 32. So it seems that we can not implement this changes today. Probably would have to do it when we will target Android 13. Just to be safe, do you have Android 13 device to verify that back button still works?

Shchvova avatar Sep 13 '22 13:09 Shchvova

Back button works as usual

On Tue, Sep 13, 2022, 16:03 Per Haglund @.***> wrote:

Ok thanks, yes i have a Pixel phone on Android 13 (worth getting for you too perhaps)

On Tue, Sep 13, 2022, 15:59 Vlad Svoka @.***> wrote:

So, I finally got to look into it. It seems that changes would come only when we'll target Android 13, api lvl 33. Now we are targeting 32. So it seems that we can not implement this changes today. Probably would have to do it when we will target Android 13. Just to be safe, do you have Android 13 device to verify that back button still works?

— Reply to this email directly, view it on GitHub https://github.com/coronalabs/corona/issues/443#issuecomment-1245455529, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACKKSVHIMJ3AB5IK6I62VXDV6CCEXANCNFSM6AAAAAAQBN5GZQ . You are receiving this because you authored the thread.Message ID: @.***>

appfamily avatar Sep 13 '22 14:09 appfamily

@Shchvova It seems it's time to move to target API level 33, today got email from Google, where they warning:

"Starting August 31, 2023: New apps and app updates must target API level 33 to be submitted to Google Play (Wear OS must target API 30)."

purejenix avatar Mar 22 '23 17:03 purejenix