Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is an activity, a context and an intent in Android? [closed]

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.

like image 794
ADJ Avatar asked Nov 18 '11 09:11

ADJ


People also ask

What is activity and intent in android?

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() .

Is activity a context in android?

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.

What is an activity in android?

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.

What is context and intent in android?

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.


1 Answers

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.

like image 76
K.Muthu Avatar answered Sep 30 '22 23:09

K.Muthu