Can somebody please explain to me what an activity, a context and an intent in Android are?
I read the Android documentation, but I could not understand these concepts.
An Activity represents a single screen in an app. You can start a new instance of an Activity by passing an Intent to startActivity() . The Intent describes the activity to start and carries any necessary data. If you want to receive a result from the activity when it finishes, call startActivityForResult() .
In android, Context is the main important concept and the wrong usage of it leads to memory leakage. Activity refers to an individual screen and Application refers to the whole app and both extend the Context class.
An activity provides the window in which the app draws its UI. This window typically fills the screen, but may be smaller than the screen and float on top of other windows. Generally, one activity implements one screen in an app.
context. startActivity(new Intent(context, ActivityClass. class)); This call to startActivity sends the Intent to the Android system, which is then in charge of creating and opening the activity that you have specified.
Activity: represents the presentation layer of an Android application, e.g. a screen which the user sees. An Android application can have several activities and it can be switched between them during runtime of the application.
ContentProvider: provides data to applications, via a content provider your application can share data with other applications. Android contains a SQLite
DB which can serve as the data provider
Intents - are asynchronous messages which allow the application to request functionality from other services or activities. An application can call directly a service or activity (explicit intent) or ask the Android system for registered services and applications for an intent (implicit intents). For example, the application could ask via an intent for a contact application. Applications register themselves to an intent via an IntentFilter
. Intents are a powerful concept as they allow the creation of loosely coupled applications.
See the following link: http://www.vogella.de/articles/Android/article.html.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With