android-activity Hello World Basic Activity structure


Example

Activity is the root UserInterface in Android and have it's own life-cycle.

MainActivity.java

public class MainActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Toast.makeText(this, "Activity created sucessfully!", Toast.LENGTH_LONG).show();
    }
}

AndroidManifest.xml (should be edited)

<manifest ... >
    <application ... >
        <activity
            android:name=".MainActivity"
            android:theme="@android:style/Theme.AppCompat">
        </activity>
    </application>
</manifest>