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

Author Topic: Android and iOS ports available for testing  (Read 338034 times)

0 Members and 6 Guests are viewing this topic.

ChronicRat

  • Sr. Member
  • ****
  • Posts: 327
  • C++ programmer
    • View Profile
    • My blog
Re: Android and iOS ports available for testing
« Reply #255 on: August 26, 2014, 08:47:37 pm »
static void onPause(ANativeActivity* activity)
{
    // Retrieve our activity states from the activity instance
    sf::priv::ActivityStates* states = sf::priv::retrieveStates(activity);
    sf::Lock lock(states->mutex);

    // Send an event to warn people the activity has been paused
    sf::Event event;
    event.type = sf::Event::MouseLeft;

    states->forwardEvent(event);
}
Why there used "MouseLeft" event? I think "LostFocus" is better.

But it is not important. I'm entering to this function when i'm exiting from my "main". If i'm calling "window->close()" before - the same. I want to get in "onDestroy" function!

AlexAUT

  • Sr. Member
  • ****
  • Posts: 396
    • View Profile
Re: Android and iOS ports available for testing
« Reply #256 on: August 26, 2014, 08:57:18 pm »
I already created an issue about this topic: https://github.com/SFML/SFML/issues/653

The problem is there should be a way to differ if onPause or onStop is called, because maybe you want to do different things.

AlexAUT

ChronicRat

  • Sr. Member
  • ****
  • Posts: 327
  • C++ programmer
    • View Profile
    • My blog
Re: Android and iOS ports available for testing
« Reply #257 on: August 26, 2014, 09:01:33 pm »
AlexAUT, do you have any trouble with exiting from app? I can normally launch/exit only once, then i need to kill app manually to launch app again. As i see in the debugger - "onDestroy" function is never called.

AlexAUT

  • Sr. Member
  • ****
  • Posts: 396
    • View Profile
Re: Android and iOS ports available for testing
« Reply #258 on: August 26, 2014, 09:21:15 pm »
onDestroy is only called when app gets deleted from the memory, for example when the system is low on memory... So its ok when onDestroy isn't called.


What do you mean with "exiting from app", do you mean when the user presses the home button? Or do you mean when your code closes the app -> main returns?
For the first case I have no problem, sf::Event::LostEvent/MouseLeft are called and sf::Event::GainFocuse/MouseEntered are called.
For the latter case I use exit(0) to close the app, otherwise I have problems when I open the app again.



AlexAUT



AlexAUT
« Last Edit: August 26, 2014, 09:24:01 pm by AlexAUT »

ChronicRat

  • Sr. Member
  • ****
  • Posts: 327
  • C++ programmer
    • View Profile
    • My blog
Re: Android and iOS ports available for testing
« Reply #259 on: August 26, 2014, 09:24:05 pm »
For the latter case I use exit(0) to close the app, otherwise I have problems when I open the app again.
That what i need, thank you!

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Android and iOS ports available for testing
« Reply #260 on: August 26, 2014, 09:26:11 pm »
For the latter case I use exit(0) to close the app, otherwise I have problems when I open the app again.
That what i need, thank you!
Just remember that "exit(0)" won't run any destructors...

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
Re: Android and iOS ports available for testing
« Reply #261 on: August 26, 2014, 09:29:50 pm »
No problems here either. Works fine as well.

Here's a compiled/packaged version of the SFML example app featuring a simple modification that will print out all events happening, making it easier to see which events are fired: https://dl.dropboxusercontent.com/u/2510538/SFML-Example-debug.apk

ChronicRat

  • Sr. Member
  • ****
  • Posts: 327
  • C++ programmer
    • View Profile
    • My blog
Re: Android and iOS ports available for testing
« Reply #262 on: August 26, 2014, 09:32:11 pm »
Just remember that "exit(0)" won't run any destructors...
Yes, I know. =) But I would never have thought of using "exit" to quit app. I just forget about it. Now I can place my games at stores.  8)

AlexAUT

  • Sr. Member
  • ****
  • Posts: 396
    • View Profile
Re: Android and iOS ports available for testing
« Reply #263 on: August 26, 2014, 09:43:25 pm »
Just remember that "exit(0)" won't run any destructors...

The problem is what are the options? When I return normally the user can't open the game again, so I created the "engine" on the heap and delete it myself before I exit(0) (btw I have no globals), but I don't know about the SFML global stuff   :-\



AlexAUT

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
Re: Android and iOS ports available for testing
« Reply #264 on: August 26, 2014, 09:49:47 pm »
This sounds like you've got some bug somewhere, possibly a race condition with static constructors/destructors?

AlexAUT

  • Sr. Member
  • ****
  • Posts: 396
    • View Profile
Re: Android and iOS ports available for testing
« Reply #265 on: August 26, 2014, 09:51:57 pm »
It also happens with the SFML-example, so I guess its not a problem with my codebase, also it does not happen on every device. Sadly I can't test it because I haven't my phone for ~2weeks (broke it last week  :'( )


AlexAUT

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
Re: Android and iOS ports available for testing
« Reply #266 on: August 26, 2014, 09:57:38 pm »
There used to be a bug similar to that in event handling a few weeks ago. Make sure you actually rebuild from scratch (delete the bin/libs/obj sub dirs), then build again. Just issuing "ndk-build" or "ndk-build -B" doesn't seem to always do the trick.

AlexAUT

  • Sr. Member
  • ****
  • Posts: 396
    • View Profile
Re: Android and iOS ports available for testing
« Reply #267 on: August 26, 2014, 10:19:01 pm »
Okay, I will try it when i have my phone back.


AlexAUT

leafdj

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Re: Android and iOS ports available for testing
« Reply #268 on: September 07, 2014, 09:04:54 pm »
Quick question about resource management on Android, I'm having a bit of a tough time reading a .txt file that I have defined in assets. I'm using an ifstream which works fine on Windows, but won't work on Android because the file is contained in the .apk. Is there a way to use the SFML Resource Manager that's used by Image Loading, etc., or is it better just to directly use the android asset manager?
Is there a way that I can get a reference to the file that can be treated the same way as the ifstream?
ie stream >> line?

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
Re: Android and iOS ports available for testing
« Reply #269 on: September 07, 2014, 10:27:17 pm »
It's not exposed yet, you'd have to write your own code around that. But I'm having the same issue, so very likely to submit something soon™.

 

anything