Solved

hello world android

Posted on 2012-03-19
15
431 Views
Last Modified: 2012-03-20
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
0
Comment
Question by:jagguy
  • 9
  • 3
  • 2
  • +1
15 Comments
 
LVL 30

Expert Comment

by:IanTh
ID: 37736948
cant see your web code
0
 

Author Comment

by:jagguy
ID: 37737095
err it was a default program, where is the web code you want?
0
 

Author Comment

by:jagguy
ID: 37737100
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);
    }
}
0
 
LVL 8

Expert Comment

by:santhanasamy
ID: 37737135
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......
0
 
LVL 47

Expert Comment

by:for_yan
ID: 37737331
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.
0
 
LVL 47

Expert Comment

by:for_yan
ID: 37737347
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
0
 
LVL 47

Expert Comment

by:for_yan
ID: 37737351
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
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 47

Expert Comment

by:for_yan
ID: 37737397
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
0
 
LVL 8

Expert Comment

by:santhanasamy
ID: 37737458
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......
0
 
LVL 47

Expert Comment

by:for_yan
ID: 37737489
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
0
 
LVL 8

Expert Comment

by:santhanasamy
ID: 37737574
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.
0
 
LVL 47

Accepted Solution

by:
for_yan earned 500 total points
ID: 37738294
This is how it looks for me.

This is the home screen of the emulator:

one
If you click on the icon with circle and squares it goess to appliaction screen:
two

Then when you click on Hello Aandroid it shows this:

three
If you just wait it will actually come to that screen irtseld - jus click Run- as Android App
0
 
LVL 47

Expert Comment

by:for_yan
ID: 37738317
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

0
 
LVL 47

Expert Comment

by:for_yan
ID: 37738333
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

0
 
LVL 47

Expert Comment

by:for_yan
ID: 37738361
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
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

A short article about a problem I had getting the GPS LocationListener working.
You should read OS supplied guidelines before developing. I can't stress that enough. The guidelines will help you understand the reasons mobile app developers do what they do.  Apple is very particular when they review appstore submissions.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now