• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps What should happen running MyFirstApp

davidsc

Lurker
I have created MyFirstApp according to the developer.android.net tutorial in Eclipse on Windows 7. I can run the application, but when I do I see nothing happen on my Samsung Galaxy 3 device or on the emulator device when I choose that instead as my target.
I thought that somehow the message "Hello World!" was going to be displayed.
Can anybody tell me what may be my problem?

These are the contents of MainActivity.java:

[HIGH]package com.example.myfirstapp;

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

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}

}[/HIGH]

David
:(
 
this is how your java file should look like

HTML:
package com.srccodes.android;
 
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
 
public class HelloActivity extends Activity {
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_hello);
    }
 
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.activity_hello, menu);
        return true;
    }    
}

follow the complete tutorial here may be you have missed out something your java file looks error free to me

http://www.srccodes.com/p/article/2...-ide-and-android-development-tools-adt-plugin
 
A couple of sort of generic things you could try.

Try cleaning (Project/clean) the project. I've found that sometimes Eclipse will highlight a problem it wasn't showing after doing this.

Look at the LogCat view. See if anything wrong gets reported there when you try to debug the app.

Use breakpoints. With your code you could for example put one on the line super.onCreate(savedInstanceState). You should be able to step over that line and the next one without problems. When you reach the closing brace, you need to resume.
 
Back
Top Bottom