My first program but I need bit of help


Last Updated:

  1. shahdharmit

    shahdharmit New Member This Topic's Starter

    Joined:
    Jul 17, 2010
    Messages:
    4
    Likes Received:
    0
    Hello,

    Following is my code
    Code (Text):
    1.  
    2. package com.example.helloandroid;
    3.  
    4. import android.app.Activity;
    5. import android.os.Bundle;
    6. import android.widget.TextView;
    7.  
    8. public class HelloAndroid extends Activity {
    9.     /** Called when the activity is first created. */
    10.     @Override
    11.     public void onCreate(Bundle savedInstanceState) {
    12.         super.onCreate(savedInstanceState);
    13.         TextView tv = new TextView(this);
    14.         tv.setText("Hello, Android");
    15.         setContentView(tv);
    16.     }
    17. }
    18.  
    As per the output presented on developer.android.com, I should be getting Hello, Android printed on the emulator. But what I get is shown in the image I've attached. What maybe the possible reason and what shall I do to overcome the problem?

    Thanks.
    [​IMG][​IMG]
     

    Attached Files:


    Advertisement
  2. Boogs

    Boogs Well-Known Member

    Joined:
    Apr 6, 2010
    Messages:
    85
    Likes Received:
    16
    It looks like your emulator hasn't booted up fully. Try shutting it down, restarting it and then restarting your program again. BTW, you should see a normal home screen after your emulator completes booting up.
     
  3. shahdharmit

    shahdharmit New Member This Topic's Starter

    Joined:
    Jul 17, 2010
    Messages:
    4
    Likes Received:
    0
    Thanks Boogs for the reply.

    I restarted Eclipse but still there's no change in the output I get. On developer.android.com I saw a very different output screen. This one seems quite different. I installed Android 2.2 packages only because of Internet speed issues. Does that make any difference? I mean do I need to install packages for older version of Android as well?

    Thanks.
     
  4. Boogs

    Boogs Well-Known Member

    Joined:
    Apr 6, 2010
    Messages:
    85
    Likes Received:
    16
    Technically, you don't have to install the packages for the earlier versions of Android, but it's a good idea. I would install at least something as old as version 1.6. If you're targeting only android 2.2 users, then you're limiting yourself to a very small percentage of people. But, to get back to your current problem-your emulator still isn't starting correctly. When it does you will see the Android home screen with the "slide to unlock" that you would normally see on an Android phone.
     
  5. shahdharmit

    shahdharmit New Member This Topic's Starter

    Joined:
    Jul 17, 2010
    Messages:
    4
    Likes Received:
    0
    I waited for some time after I got the screen that I posted in my 1st post. And then I got the emulator working properly. And also the Hello Android program worked fine. Thanks for your inputs. :)
     
  6. cp1

    cp1 Well-Known Member

    Joined:
    Apr 30, 2010
    Messages:
    375
    Likes Received:
    35
    It's just like booting your phone, only slower. So be patient.
     

Share This Page

Loading...