What Is Activity In Android | Activity In Android Studio | Android Activity Explained In Detail


What is Activity?

An activity is one screen of the Android app. In that way, an Android activity is very similar to window in windows operating system.

To be more specific, the building block of the user interface is the activity. An Android app may contain one or more activities, meaning one or more screens. For e.g. Login, Sign-up & Home screen.

And activity class is a predefined class in Android and every application which has UI must inherit it to create window.

How Activity works?

Activity in Android is a platform or a specifically combination of XML file and Java file It is basically a container which contains design as well as coding stuff.

XML file provides you with the design of your screen.

Java file deals with all the coding stuff like handles what's happening in the design file, getting data which user has inserted into it.

How to create an Activity?

Way 1:

  • Create XML file (add “activity_” before file name. E.g. activity_main.xml).
    • Insert Relative Layout & TextView in xml file.

  • Create java file (add “Activity” after the file name, e.g. MainActivity.java).
    • Override  onCreate(Bundle savedInstanceState) Method.
    • Call setContentView(R.layout.activity_main)

  • Declare activity in the manifest.
    • If you want to make activity as first screen. Write these tags inside activity tag.
      
      
      
      
      


Way 2 (Bonus):

Create all activity component automatically using android studio wizard (watch the video for that).

That's all Folks, if you still have any confusion, clear them by commenting below.
And Be Updated with our YouTube Channel.

Comments

  1. I think this is the minimum value to earn more than just commitdata science certification malaysia

    ReplyDelete
  2. Happy to visit your blog, I am by all accounts forward to more solid articles and I figure we as a whole wish to thank such huge numbers of good articles, blog to impart to us.
    data science course in delhi








    ReplyDelete
  3. I think I have never watched such online diaries ever that has absolute things with all nuances which I need. So thoughtfully update this ever for us.
    https://360digitmg.com/course/project-management-professional-pmp

    ReplyDelete
  4. This site is astounding data and realities it's truly fantastic
    data science course in aurangabad

    ReplyDelete
  5. wonderful article. Very interesting to read this article. I would like to thank you for the efforts you had made for writing this awesome article. This article resolved my all queries. Mason

    ReplyDelete
  6. Cool you write, the information is very good and interesting, I'll give you a link to my site.
    data science courses in aurangabad

    ReplyDelete

Post a Comment