1. Download our Official Android App: Forums for Android!

Code not working on android

Discussion in 'Android Apps & Games' started by ANDRN, Feb 16, 2011.

  1. ANDRN

    ANDRN Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    2
    Joined:
    Feb 12, 2011

    Feb 12, 2011
    2
    0
    5
    I am using the following simple code but its not working.

    Here is the full code that I am using:
    <!DOCTYPE HTML>
    <html>
    <head>
    <title>Contact Example</title>

    <script type="text/javascript" charset="utf-8"
    src="phonegap-0.9.3.js"></script>
    <script type="text/javascript" charset="utf-8">

    function onLoad() {
    document.addEventListener("deviceready", onDeviceReady, false);
    }

    function onDeviceReady() {
    var element1 = document.getElementById('myname');
    element1.innerHTML = "Ritesh";

    var element2 = document.getElementById('deviceProperties');
    element2.innerHTML = device.name ;

    }

    </script>
    </head>
    <body onload="onLoad()">
    <p id="myname">Some text here</p>
    <p id="deviceProperties">Loading device name</p>

    </body>
    </html>


    And here is the console log:
    [2011-02-15 10:45:51 - MyPhonegapAppL1] Android Launch!
    [2011-02-15 10:45:51 - MyPhonegapAppL1] adb is running normally.
    [2011-02-15 10:45:51 - MyPhonegapAppL1] Performing com.ex.L1.MyApp
    activity launch
    [2011-02-15 10:45:51 - MyPhonegapAppL1] Automatic Target Mode: using
    existing emulator 'emulator-5554' running compatible AVD 'HelloAvd'
    [2011-02-15 10:45:51 - MyPhonegapAppL1] WARNING: Application does not
    specify an API level requirement!
    [2011-02-15 10:45:51 - MyPhonegapAppL1] Device API version is 9
    (Android 2.3.1)
    [2011-02-15 10:45:51 - MyPhonegapAppL1] Uploading MyPhonegapAppL1.apk
    onto device 'emulator-5554'
    [2011-02-15 10:45:52 - MyPhonegapAppL1] Installing
    MyPhonegapAppL1.apk...
    [2011-02-15 10:45:55 - MyPhonegapAppL1] Success!
    [2011-02-15 10:45:55 - MyPhonegapAppL1] Starting activity
    com.ex.L1.MyApp on device emulator-5554
    [2011-02-15 10:45:56 - MyPhonegapAppL1] ActivityManager: Starting:
    Intent { act=android.intent.action.MAIN
    cat=[android.intent.category.LAUNCHER] cmp=com.ex.L1/.MyApp }


    But its not working. All I see is -
    "Some text here
    Loading device name"
    And then the application exits. Can you please help me figure out?
    Thanks so much in advance.

    PS - I am using Eclipse/Phonegap on windows
     

    Advertisement

Share This Page

Loading...