android-activity

Hello World

Remarks#

onCreate() is the most essential part of an activity, it’s where most of your activity logic goes.

Basic Activity structure

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>

This modified text is an extract of the original Stack Overflow Documentation created by the contributors and released under CC BY-SA 3.0 This website is not affiliated with Stack Overflow