jaunesarmiento / fries

Fries helps you prototype Android apps using HTML, CSS, and JavaScript.
MIT License
1.55k stars 222 forks source link

Back button on Android quit application #35

Closed aboudard closed 10 years ago

aboudard commented 11 years ago

I'm sorry if this issue is already out, I couldn't find a topic about it.

The problem is quite simple, the back button makes you leave the application even if you are in a "second" screen (like contacts.html in demo content). Is it "normal" considering the use of stack.js ?

My config : Phonegap 2.7.0 on Android 4.1.2

jaunesarmiento commented 11 years ago

Hi there @aboudard, no I believe this is not "normal". What version of Fries are you using?

aboudard commented 11 years ago

I use 1.0.0 according to the readme, I juste downloded the master. I tried just now to catch the backbutton with phonegap, but with no success, I try harder :D

jaunesarmiento commented 11 years ago

Alright. Can you try doing a console.log() inside the code where you try to catch the back button? I'm very willing to help you with your problem. :)

aboudard commented 11 years ago

I am right now :) I can't load any console at all on new-contact.html ...

Added this in the bottom of the page (works perfect in index.html)


<script src="js/cordova-2.7.0.js"></script>
<script>
    window.addEventListener('load', init, false);
    function ready(e){
        console.log("Loaded");
        document.addEventListener("backbutton", onBackKeyDown, false);
    }

    function onBackKeyDown() {
        window.history.go(-1);
        console.log("Back");
    }

    function onError(error) {
        console.error(JSON.stringify(error));
    }

    function init(e){
        document.addEventListener('deviceready', ready, false);
        console.log("Init Loaded");
    }
</script>
jaunesarmiento commented 11 years ago

But will the app still exit if you press the back button on index.html?

Edit: I currently don't have an Android phone right now that's why I'm asking. xD

aboudard commented 11 years ago

Well, it seem like there is really a problem with the back button, when I have activated multiple tabs, it looks like application is freezing, and sometimes I see the pages with no style at all ... pretty bad ... I try to see if this behavior is caused by the webview component, I'll install Fries on a http server to be sure.

jaunesarmiento commented 11 years ago

Hmm. That's odd. Is there any particular reason why you're catching the back button functionality? Cause when I tested this, I never had to catch the back button and still it works fine.

By the way, the style on other pages does not load if stack.js fails to load properly in index.html.

aboudard commented 11 years ago

Yes, that's very strange. here is what I did :

aymanfarhat commented 11 years ago

@aboudard I just tested your code for the back button issue on a phonegap project with Fries, the problem is non existent. In addition to that I highly doubt that the problem is stemming from stack.js , I suggest trying on the side a new Phonegap project without Fries and implement dynamic page loading (which is similar to how Stack.js does) and test the app on the same device.

aboudard commented 11 years ago

Well there is no "code of mine" to test, my simple test was to install both on a device and an emulator a simple Android / Phonegap app with fries demo pages. I will try to work on a brand new project like you say, thanks for the advice.

aboudard commented 11 years ago

Ok, I made a new Phonegap app with phonegap build, starting from both sample project from Fries and Phonegap-start, and the problem doesn't happen !

My first phonegap project (with the bug) was built with the Android dedicated ant command line "create" ... I will try to reproduce, that might be a good advice ... not using this build ... :| that would be more relevant than saying "non existent" ;)

jaunesarmiento commented 11 years ago

Thanks @aymanfarhat. I couldn't test the problem.

@aboudard you could also try to build and install https://github.com/jaunesarmiento/HelloFries on your device. That project was made using ./create <project_folder_path> <package_name> <project_name> command from the Cordova Android distribution.

jaunesarmiento commented 10 years ago

Back button seems to be working fine on v2.0.0