Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Android example can not close on Escape  (Read 18302 times)

0 Members and 2 Guests are viewing this topic.

Demir

  • Newbie
  • *
  • Posts: 22
    • View Profile
    • Email
Android example can not close on Escape
« on: February 06, 2016, 03:08:46 pm »
Hello,

I try to run android example through wiki "Tutorial: Building SFML for Android".
As was expected it worked.

I added Escape key release checking to close via Back button on the tablet.
if (event.type == sf::Event::KeyReleased)
{
  if (event.key.code == sf::Keyboard::Escape)
  window.close();
}
 
It can not close properly.
Any idea ? What can I do ?

Thanks

Edit:
I noticed same question at this link :(
http://en.sfml-dev.org/forums/index.php?PHPSESSID=ot7h2v1oj9hmn1qop9q78i4s03&topic=19145.msg141108#msg141108
« Last Edit: February 06, 2016, 04:33:50 pm by Demir »

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Android example can not close on Escape
« Reply #1 on: February 06, 2016, 03:18:41 pm »
Have you tried logging what key.code is actually generated? Maybe it's just not Escape as you expect but some other key code...

Demir

  • Newbie
  • *
  • Posts: 22
    • View Profile
    • Email
Re: Android example can not close on Escape
« Reply #2 on: February 06, 2016, 03:49:34 pm »
Returning key code is 36 it is Escape in "Keyboard::Key" enum.

On Escape It closes the example applicatin but after that .... the example app can not work again only black screen appears.

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
Re: Android example can not close on Escape
« Reply #3 on: February 10, 2016, 12:42:38 pm »
Make sure to leave your main() after you've closed the window. Any chance you forgot doing that?

Demir

  • Newbie
  • *
  • Posts: 22
    • View Profile
    • Email
Re: Android example can not close on Escape
« Reply #4 on: February 11, 2016, 11:45:09 am »
Quote
Make sure to leave your main() after you've closed the window. Any chance you forgot doing that?

I hope it gives you an idea to find close problem.
as I can see
std::exit(0);
can close completely.

1. I tried to control via isClosed boolean var. does not work
                if (event.key.code == sf::Keyboard::Escape)
                {
                    isClose = true;
                    window.close();
                }
 

2. I tried to return 0 does not work
window.close();
return 0;
 


R23MJ

  • Jr. Member
  • **
  • Posts: 50
    • View Profile
Re: Android example can not close on Escape
« Reply #5 on: May 03, 2016, 03:44:21 pm »
From what I remember when working with iOS, you cannot actually close the application from within the application. Which makes sense if you think about it, the user needs to close the application via system supplied ways, i.e. pressing home button.

korczurekk

  • Full Member
  • ***
  • Posts: 150
    • View Profile
    • Email
Re: Android example can not close on Escape
« Reply #6 on: May 04, 2016, 05:19:28 pm »
From what I remember when working with iOS, you cannot actually close the application from within the application. Which makes sense if you think about it, the user needs to close the application via system supplied ways, i.e. pressing home button.
You can close app within code on iOS, but if so you have no chances for getting into appstore. And android applications often close themselves, so there must be some other error.

ChronicRat

  • Sr. Member
  • ****
  • Posts: 327
  • C++ programmer
    • View Profile
    • My blog
Re: Android example can not close on Escape
« Reply #7 on: May 04, 2016, 06:11:04 pm »
The only way to totally finish Android app is to call exit() or std::terminate() function. exit() is bad if you'll relaunch app immediately after exit. terminate() is bad because it shows popup window with error message (but it's rarely, tbh I saw it two or three times).

 

anything