Game Maker Studio Android Native Extension – Close Game Popup

Hello there!

Handling the Back Button within your game is really important.
Google offers its navigation guidelines, for giving the users always the same experience.
Check them here:

Regarding the back button, it should close any window, message or popup, and it should bring the navigation back until the main menu.
Once there, by clicking the back button again the users expect to close the game.
And, usually, a popup message like “Are you sure you want to quit? – Yes – No” is shown at this point.

In Game Maker, you can handle the Android native back button just with the “Release Backspace” event,
and, from there, handle all the navigation untile the main screen.
Then, you’ll have to create your own quit popup and call game_end() when the user clicks “yes”, or dismiss it if the user clicks “no”.

However, as in my case, you may need, or may want, to show an Android native popup, instead, to be sure, for example, that it will be above all the graphics, that it will pause the game and that it is runned in a dedicated activity.

For this reason, I’ve created the closeGameAndroidEx Extension for Game Maker Studio.

Just call:

closeAndroidGame(String messageString, String yesString, String noString)

to show the popup with your customized messages.

For example:

closeAndroidGame(“Are you sure you want to quit this awesome game?”, “Yes”, “No”)

will open the popup as below:

screen1 screen2

Well, you can get my closeGameAndroidEx for FREE from the Game Maker Marketplace.

If you want to see the extension in action, try out my Alpaca Jump:
In which this feature will be available from its 1.0.5 version (still not realeased at the moment of writing).

Thanks for reading, and, as ever, for any tip or suggestion, feel free to write a comment or send me an email.

Have a nice day,



  • Hello Mattia, good day, I love to try this extension of game maker that you created but unfortunately I don’t I cannot download it on YoyoGames Market as I don’t have the money yet to buy the android extension. I only have the Studio Professional license version but I also have a master collection pirated version. I just want to try it. If you could e-mail me the extension I would be very happy to try it. Thanks.

    PhilipDecember 22, 2014
  • Hello Philip,
    thanks for your interest in my extension, I’m always glad to help my Game Maker fellows 🙂
    Obviously you won’t find my support regarding any pirated software.
    Instead, let me suggest you to get a legal copy of the Android Export for Game Maker as soon as possible, it’s really worth and totally affordable!
    Well, on the other hand, for sure, you can have my full support regarding my Close Game Popup extension 🙂
    I’m sending you an email right now, attaching my Close Game Popup extension ^^

    Mattia FortunatiDecember 23, 2014
  • hi mattia , sorry for this
    this extension very usefull for me and can help me to create android extension but ,
    market place unavailable in our country and me can’t download it , can you send to my mail but if you can’t send this to me , no problem very thanks .
    sorry my first language not english .

    aminMay 20, 2015
  • Hello Amin,
    I’t a pity that the Marketplace isn’t still availabe in your country!
    But don’t worry, I will be really happy to help you out! 🙂
    I’m sending you an email right now, with the last version of my Close Game Popup extension as attachment.
    I hope that this can help you with your project! Cheers! 😀

    Mattia FortunatiMay 21, 2015
  • Hi Mattia

    I am looking this extension for the whole time. however my country and ISP blocked several sites due to cyber policies and I cannot acces the marketplace. Plus you know I cannot buy some of extensions I see bcause I have no money and just 13 years old. Can you please send me a copy of it on my email:…. but If you cannot send it for some good reasons.. Ill understand. Thank you!

    MahmoudMay 21, 2015
  • Hi Mahmoud,
    don’t worry, I’ll be happy to help you, too! 🙂
    I’ve just emailed you my Game Maker Studio “Close Game Popup” extension.
    Cheers! 🙂

    Mattia FortunatiMay 22, 2015
  • Hey Mattia,

    I’d love to use this extension in my game, but game maker marketplace doesn’t let me create an account because it cant register my phone number.
    Would you please send the extension to me aswell, this would be greatly appreciated!
    My email is

    Thanks in advance!

    StefanJune 14, 2015
  • Hello Stefan,
    I’ve just sent you a copy of my extension 🙂
    I’m always happy to help my fellow game developers!
    Thank you for using my codes!
    Cheers! 😀

    Mattia FortunatiJune 15, 2015
  • Hello.
    can I use it within commercial project for free?

    JCJMJanuary 4, 2016
    • Hi JCJM,
      thanks for the interest in my extension! 😀
      Sure, I can confirm you that you can use my Close Game Popup extension for Game Maker in your commercial projects for free.
      If you need more information about the extension’s terms of use, check the Game Maker Marketplace default EULA here.
      Credits to me are optional and not needed for implementing my extension within your application, but, obviously I will be really happy if you decide to mention me in your application’s credits! ^^
      Also, feel free to leave a link to your application when it will be out so I can give it a try! 🙂
      Have a nice day! 🙂

      Mattia FortunatiJanuary 4, 2016
  • Hi, Mattia, I forgot, how to use this? I mean when I want to put it in a backspace function, do I need an if else statement if should I quit or continue? Thanks!

    Harry G.May 14, 2016
    • Hi Harry,
      when you call the extension, the game pauses.
      If the user hit the “Yes” button the game will close.
      Clicking the “No” button will just return to the game, unpausing it.

      So you don’t need any check.

      For example for my Alpaca Jump game, within the Backspace release event I simply put this:
      closeAndroidGame(“Are you sure you want to quit this awesome game?”, “Yes”, “No”)

      I hope this can been helpful ^^
      Have a nice day!

      Mattia FortunatiMay 16, 2016
  • Hi Mattia!

    I’m having a strange problem, and it’s popping up in ALL of your extensions. They all throw exception errors when I try to call them.

    Now, the previous extension I added works fine (a native DatePicker), so I know extensions in general are working and running on the android device itself.

    But I’m 100% sure that I did something _then_ that I’m forgetting to do _now_ because the three extensions of yours that I’ve tried all throw exceptions.

    logToConsole(“Calling showInputText”)

    04-20 22:17:29.455 4418 4438 I yoyo : Exception thrown trying to call method logToConsole on logToConsoleEx

    showInputText(“Title Text”, “OK”, “Cancel”)

    04-20 22:17:29.465 4418 4438 I yoyo : Exception thrown trying to call method showInputText on inputTextClass

    var prompt=”Are you sure you want to exit?”
    var yes=”Exit”
    var no=”Stay”

    04-20 22:17:35.405 4418 4438 I yoyo : Exception thrown trying to call method closeAndroidGame on closeGameAndroidEx

    I’m not new to programming, but I am new to Android programming in GM:S, and Android in general. So, I don’t know how to catch these exceptions to see what’s going on. I’ve increased the minimum API to 11 as you mentioned in another post, but that didn’t fix the problem.

    Any idea what I’m doing wrong?

    GabrielApril 21, 2017
    • Hi Gabriel!

      Since it seems like a generic issue, and it is happening even for the logToConsole extension, which is really simple, it could, maybe, be an issue related to some project settings, or Game Maker Studio version.
      I can’t be sure of course since it’s a generic exception throw, but I’m guessing that because the extensions are still working fine if I try them on a test project of mine.

      Let’s see if I can give you some more help 🙂
      First of all: are you working on Game Maker Studio or on Game Maker Studio 2? Please note that my extension are NOT TESTED on Game Maker Studio 2 so it is totally possible that they are not working fine for it.
      Then, let me copy-paste some generic tips that already helped a fellow developer in the past, from here:

      Here they are:
      -which version of GMS are you actually using? I’m using Game Maker Studio version 1.4.1763
      -try to clean the target before building again.
      -try to uninstall the extension and re-install it again.
      -try to check once again your Android tabs within “File > Preferences” and “Global Game Settings”.
      -try to do as I did: create a new project and just add something like “showInputText(“Please, insert your PROMO CODE”,”Ok”, “Cancel”)” in a “Glob Left Release” Mouse Event as see if it works. If it still doesn’t work check the preferences and settings again.
      -finally, if you are using some Game Maker Early Access Build, in some cases, you need to add this: compile ‘’ into the extension’s “inject to Gradle dependencies” box. I’ve never needed or tried it though.
      Thanks go to Tom for this suggestion.

      I hope that these info can be a good starting point for you to isolate and fix the issue.
      Happy coding!

      Mattia FortunatiApril 21, 2017
    • Wow, what a fast response!

      v1.4.1763 here as well. Hrmm… if I make a new project with one of your extensions, it works. If I add a second extension, it fails….


      Oh my. Everything is working now, haha. I *knew* I was missing a step (clean the target build after adding an extension).

      Thank you for your help and your patience and your extensions.

      GabrielApril 21, 2017
      • Great, nice to hear that you solved the problem! 😉
        And thanks for sharing the correct solution so that other developers can benefit from it! 🙂
        Good luck with you project!

        Mattia FortunatiApril 21, 2017

Leave a Reply

%d bloggers like this: