Avatar of jagguy
jagguy
Flag for Australia asked on

hello world android

I have installed android/ eclipse and created a hello world app.
I seem to get the right output if I wait a while.

Is the output correct with my setup for a hello world app?

Note Android projects appear in 'other' menu only

PS:I advise dont install ADT when dealing with proxies as they are troublesome with win7
android2.docx
JavaAndroid

Avatar of undefined
Last Comment
for_yan

8/22/2022 - Mon
IanTh

cant see your web code
jagguy

ASKER
err it was a default program, where is the web code you want?
jagguy

ASKER
package myone.and1;

import android.app.Activity;
import android.os.Bundle;

public class Test1Activity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
}
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
Santhana

Hi jagguy,
I did n't understand your question....


Is the output correct with my setup for a hello world app?

==> What does it mean??? If you run your code you will get the output "test1"(By default)...

Note Android projects appear in 'other' menu only
==>  This is correct only...I am not seeing any thing wrong  in this......
for_yan

I di like here:
http://developer.android.com/resources/tutorials/hello-world.html

so you need to change your code to this, with TextView and the real words "Hello Android"
and removing the last line      setContentView(R.layout.main);

This is the code:


package com.example.helloandroid;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

public class HelloAndroid extends Activity {
   /** Called when the activity is first created. */
   @Override
   public void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       TextView tv = new TextView(this);
       tv.setText("Hello, Android");
       setContentView(tv);
   }
}

Open in new window


and  then indeed it takes quite a while - to creeate the actual emulator - device - if I dodn't toucvh it the whole thing after I say project run as android on my eclipse it takes probably five minutes

I guess after you already really see the device you can speed it up a little bit clicking on the "OK" and then clicking on this icon with the circle and the icons witin and then clicking on the Hello Android icon itself to run the application. It will do it itself but then it is still slower.
for_yan

after that you can modify your words, , say change

  tv.setText("Hello, Android");

to

  tv.setText("Hello, my jagguy Android");

and go again to Run as Android application

and at least for now for me it again goes through the whole process creating the whole device again but then you see it appearing on the screen - the icon is the same (Hello Android)
butr when you click it wriotes new words
I don't know yest - is it possible not to go through the whole creation of the device for tyhhe second time ,as it is really slow

By the wy in your screenshot - I don't see the Hello ANdroid application itself - I see only emulator
I don't even see the icon - circle with icons inside which leads to the folder with applications - in that folder I see many "native" applications and also my Hello android icon, and when it eventually starts it takes the whole screen of your device and writes Hello Android on the very top as the header (name of the app) and below your actual woords Hello Android, or Helly, my jagguy Android, whateve you actulally tyope in TextView
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
for_yan

and in my eclipse after I installed ADT and everything when I go to File -- New -Projects
I then see the option Android Project - don't rememeber that is is somethiong in Other projects
I'll check later today and can send you screnshots I hope when I get back to that computyer where I ran it
for_yan

so if you go here
http://developer.android.com/resources/tutorials/hello-world.html


in the section Run Application there is a screenshot - that is how it uiltimately should look when it runs, though it is more beautiful in my picture - I think I have this 4.0.3 platform and their snpashot is older, but te idea is the same - the app takes the fiull screen at the very top it wries application name Hello Android and below the contents of your line tv.setText("Hello, Android");

I think I have a little bit different view of the oeriginal device when it starts, as I don't have this big wide whitish button at the very bottom, again maybe that is 4.0.3 version which I chose
and mine also has amond  afew icons at the bottoms sucbh circe and insiode rows of squares - this is the icon where I click and it shows the whole screen of different applications and among them my Hello Android with standard android icon
Santhana

Hi jagguy,

You no need to do any thing  to display "hello World"...If you create a android project in ecllipse it will automatically create a activity(During project setup it will ask the Activity name)...By default it will display the hellow world with your project name.......ex : "Hello World!, test1!"

First time it will take some time to execute your project...Next time if you run your project with out changing any resources it will be faster......
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
for_yan

In my envioinemnet (as I struictly followed the instructions in the link
http://developer.android.com/resources/tutorials/hello-world.html
)  it did not ask me for any activity (just Run as Android project was my last commad) and for some reason it was not faster second time. Even when I went to Histrory- Run the same project agaian it took the wholke time and created the new emulator window. Perhaps I don;tknow how to avloid it
Santhana

Hi jagguy,

Menu -> Run -> Run Configurations--> Here u can see the option to run the project. Select your project in the left side window....In the Right side pan select Target. Here you can find the 2 options manual & Automatic. Select automatic and below that you can find the list of available devices / Emulatore and check any one of tham...

From next time onwards If you run your project it will directly launch your app through that device/emulator. It will not launch the new emulator again from the boot screen.
ASKER CERTIFIED SOLUTION
for_yan

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
for_yan

nad this the exact code correspodning to the above pictures:

package com.exmple.helloandroid;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

public class HelloAndroidActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        TextView tv = new TextView(this);
        tv.setText("Hello, new Android");
        setContentView(tv);

        //setContentView(R.layout.main);
    }
}

Open in new window

⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
for_yan

This is the eclipse console output:

[2012-03-19 08:37:42 - HelloAndroid] ------------------------------
[2012-03-19 08:37:42 - HelloAndroid] Android Launch!
[2012-03-19 08:37:42 - HelloAndroid] adb is running normally.
[2012-03-19 08:37:42 - HelloAndroid] Performing com.exmple.helloandroid.HelloAndroidActivity activity launch
[2012-03-19 08:37:42 - HelloAndroid] Automatic Target Mode: launching new emulator with compatible AVD 'my_avd'
[2012-03-19 08:37:42 - HelloAndroid] Launching a new emulator with Virtual Device 'my_avd'
[2012-03-19 08:37:50 - Emulator] emulator: WARNING: Unable to create sensors port: Unknown error
[2012-03-19 08:37:50 - HelloAndroid] New emulator found: emulator-5554
[2012-03-19 08:37:50 - HelloAndroid] Waiting for HOME ('android.process.acore') to be launched...
[2012-03-19 08:39:21 - HelloAndroid] HOME is up on device 'emulator-5554'
[2012-03-19 08:39:21 - HelloAndroid] Uploading HelloAndroid.apk onto device 'emulator-5554'
[2012-03-19 08:39:21 - HelloAndroid] Installing HelloAndroid.apk...
[2012-03-19 08:40:23 - HelloAndroid] Success!
[2012-03-19 08:40:23 - HelloAndroid] Starting activity com.exmple.helloandroid.HelloAndroidActivity on device emulator-5554
[2012-03-19 08:40:25 - HelloAndroid] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.exmple.helloandroid/.HelloAndroidActivity }
[2012-03-19 08:44:04 - HelloAndroid] ------------------------------

Open in new window

for_yan

And going through Run Configurations and selecting Target and clickin on device as
santhanasamy suggested did help in a sense taht when I now say modify the text and run it aggain - it really does not create a new emeulator but replaces the program in the current emulator and it is indeed much faster