1. android-studio-hello-android-example

Hello Android Example with Android Studio


Here is the basic syntax for creating a "Hello World" message in Android Studio:

public class MainActivity extends AppCompatActivity {
    protected void onCreate(Bundle savedInstanceState) {

        // Display "Hello World!" message
        Toast.makeText(getApplicationContext(), "Hello World!", Toast.LENGTH_LONG).show();


Here is an example of how to implement the "Hello World" message in Android Studio:

  1. Open Android Studio and create a new project.
  2. In the project explorer, navigate to app > java > com.example.yourappname > MainActivity.
  3. Replace the existing code with the code provided in the Syntax section.
  4. Run the app on an emulator or your Android device.


When you run the app, a message saying "Hello World!" will appear on the screen, using the Android Toast class.


This code creates an activity, which is the main entry point of the app. The onCreate() method sets the layout of the activity to activity_main.xml. Then, it uses the Toast.makeText() method to create a pop-up message that displays the text "Hello World!".


The "Hello World" example is a simple way to get started with Android development in Android Studio. It demonstrates how to create an activity, set a layout, and use the Toast class to display a message.

Important Points

  • The onCreate() method is called when the activity is created.
  • The setContentView() method sets the layout of the activity to the XML file specified.
  • The Toast.makeText() method creates a message that pops up on the screen.
  • The Toast.LENGTH_LONG parameter sets the duration of the message to be displayed.


In this example, we learned how to create a "Hello World" message in Android Studio using an activity, layout, and the Toast class. This simple example is a great way to start learning Android development in Android Studio.

Published on: