Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Minimal" source files to create Android app using Eclipse + ADT

Tags:

android

I am trying to understand the anatomy of a MINIMAL Android application, using Eclipse + ADT (Android Development Toolkit).

Please can you advise what is the MINIMAL set of source files I need, for example :-

src / package / MainActivity.java
res / layout / activity_main.xml
res / menu / activity_main.xml  (??)
AndroidManifest.xml
(any other source files needed?)

Please can you advise what is the MINIMAL that I need to put into each file in order for it to run on the AVD (Android Virtual Device) ?

For example, which of these files needs to contain reference(s) to which other files, etc?

like image 421
James Avatar asked Aug 09 '12 17:08

James


1 Answers

Strictly speaking the minimal project that displays Hello World is

.
├── AndroidManifest.xml
├── res
└── src
    └── com
        └── example
            └── minimal
                └── Minimal.java

Minimal.java

package com.example.minimal;

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

public class Minimal extends Activity {

    /* (non-Javadoc)
     * @see android.app.Activity#onCreate(android.os.Bundle)
     */
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        final TextView tv = new TextView(this);
        tv.setText("Hello World!");
        setContentView(tv);
    }

}

AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.minimal"
    android:versionCode="1"
    android:versionName="1.0">

    <uses-sdk android:minSdkVersion="15" android:targetSdkVersion="15" />

    <application android:label="Minimal">
        <activity android:name="Minimal">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
            </intent-filter>
        </activity>

    </application>

</manifest>
like image 173
Diego Torres Milano Avatar answered Sep 21 '22 12:09

Diego Torres Milano