Problem is writing device name to the AVD

  • Replies:6
  • OpenNot stickiedUnanswered

Feb 13, 2011 4:13:14 PM via Website

I am using the following code in function onLoad() to write the device name:
element.innerHTML = 'Device Name: ' +;

But it is not showing up. I guess this is not working. Is this an AVD problem or some permissions required in the manifest file?

Feb 19, 2011 2:09:34 PM via Website

No I haven't tried on a real phone. Just on the emulator. What should I do to make it work? You mentioned that the emulator may not have a device name. How to set that?

Feb 19, 2011 2:11:49 PM via Website

Here is another version of the code but its not working -

<title>Contact Example</title>

<script type="text/javascript" charset="utf-8"
<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 = ;


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


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
[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.

Feb 19, 2011 5:02:46 PM via Website

Ok, I did not realize you were doing this with html. I looked at the avd options and couldn't find any info on how to set a device name. Here is some links for avd info:

My suggestion would be to do the testing of the app on an actual device. At least once to see if the emulator is the problem getting the device name. If you get no device name testing with an actual device please let me know. Sorry I couldn't help more.