facebook

Device Ready event MyEclipse: CLOSED

  1. MobiOne Archive
  2.  > 
  3. Getting Help – General
Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #352778 Reply

    Update – see http://www.genuitec.com/support-genuitec/viewtopic.php?p=28172#p28172 for the fix.

    I am attaching a deviceready event handler in the documentReadyHandler and it works fine with Mobione
    But when I am using the same code with MyEclipse and phonegap build the deviceready event is never fired

    
    phoneui.documentReadyHandler = function() {
        document.addEventListener("deviceready", deviceReady, false);
    
    }
    
    
    function deviceReady(event) {
    ...
    }
    
    #352794 Reply

    support-michael
    Keymaster

    Let me begin by asking if you were successful creating the date-time app in the tutorial. If not, start there to get a working example as a reference pt (a baseline) before customizing it or working on your own projects. After you have the date-time project building and operating correctly try making a small mod such as device-ready handler. If it is successful then compare this project with your main project to identify what is different. Also give GapDebug a try to help more quickly isolate problems.

    I added a deviceready handler in the date-time project of the tutorial. It works as expected when I register the devicereadyhandler in the phoneui.documentReady() function. See the screenshot below where my deviceready handler outputs a msg to console.log when it fires. I used GapDebug (http://genuitec.com/gapdebug) to inspect the app when running on my device. See attachment date-time-deviceready.jpg

    Attachments:
    You must be logged in to view attached files.
    #352795 Reply

    Hi Michael

    Thank you for your reply. I have followed the tutorial and used the datetime project to be sure. The thing is it does not work on the actual device. Please install your application on a device and run it see the QR code for the app

    Please install on actual device and check.

    You can download the zip of both the mobione date project and the converted project here. I have removed the .metadata folder as it was too big
    http://www.dappto.com.au/mobitest.zip

    Looking forward to hearing back from you

    #352801 Reply

    Hi,

    One issue is all your alerts are trying to trigger at the same time.
    The phone ui document handler is an device ready call and you are placing another device ready call inside that one.

    My first suggestion is to start smaller. Take out all your custom code so you only have:

    phoneui.documentReadyHandler = function() {
    alert(“Document is ready”);
    }

    And see if the alert comes up when its ready.

    #352802 Reply

    Hi Brandon

    Have you tried to install this on an actual device. I have removed all alert other than the device ready yet the same. Device ready not firing.

    Can you please try it on a device It is not working

    
    phoneui.documentReadyHandler = function() {
        //alert("documentReadyHandler");
        document.addEventListener("deviceready", deviceReady, false);
        //alert("documentReadyHandlerEnd");
    }
    
    function deviceReady() {
        alert("device is ready!!!!");
    }
    
    #352803 Reply

    Also document ready is not the problem. documentready event fires fine. It is the device ready event that never fires

    #352805 Reply

    I will try to install it a little later. You should try separating them as well, the device could already be ready.

    phoneui.documentReadyHandler = function() {
    //alert(“documentReadyHandler”);
    //alert(“documentReadyHandlerEnd”);
    }

    \\Call device ready
    document.addEventListener(“deviceready”, deviceReady, false);

    function deviceReady() {
    alert(“device is ready!!!!”);
    }

    If this still does not work I will put together a sample.

    #352807 Reply

    Here is the latest code that I tried but still no luck. Please try it on device and tell me if it works for you. I have tried 2 android devices

    
    phoneui.documentReadyHandler = function() {
        //alert("documentReadyHandler");
        //document.addEventListener("deviceready", deviceReady, false);
        //alert("documentReadyHandlerEnd");
    }
    
    //attaching deviceready outside document ready
    document.addEventListener("deviceready", mydeviceReady, false);
    
    function mydeviceReady() {
        alert("device is ready!!!!");
    }
    
    #352813 Reply

    support-michael
    Keymaster

    I was able to dig into your zip. The issue is the startup file (date-time.html) is not properly configured. Make the following 2 changes and then rebuild and test. I noticed there was a www/date-time dir in your MyEclipse project which leads me to think that you might have misconfigured the importMobioneProjectContent.ant at one pt. I don’t think that should have resulted in the date-time.html from being edited by the script. Looking into that now.

    In the meantime please make the following 2 changes, build an app and test it. deviceready handlers will always be called unless there is an error in the project on startup somewhere. I’m encouraging all phonegap developers to adopt GapDebug to investigate these type of issues. It will point out this issue in 30 seconds on startup. See attachment bad-auto-edits-for-startupfile.png

    Attachments:
    You must be logged in to view attached files.
    #352817 Reply

    Hi

    That seems to have fixed the problem. However note that running mobione and regenerating the html file will again go back to minimal-ui and rte/cordova.js

    So I think this has to be manually edited everytime you import. Also note I think this is the reason people are having the statusbar issue as the line in phoneui.js which uses the statusbar plugin never get executed. It seems the downloaded date-time project has this manually fixed. If you import it directly into MyEclipse it works but if you first run mobione and then import it it does not work. I believe you need to fix this in the docs

    
            //navigator.splashscreen.hide();
            if (typeof StatusBar != "undefined") {
                StatusBar.overlaysWebView(false);
            }
    
    #352823 Reply

    support-michael
    Keymaster

    I uploaded a new version of the tutorial resource pack (ver 0.1.3). It includes 2 fixes, including the issue affecting your project. See the updated ANN here:
    http://www.genuitec.com/support-genuitec/viewtopic.php?f=2&t=7747&p=28112

    Marking this thread CLOSED.

Viewing 11 posts - 1 through 11 (of 11 total)
Reply To: Device Ready event MyEclipse: CLOSED

You must be logged in to post in the forum log in