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

折月煮酒 提交于 2019-12-20 08:58:01

问题


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.


回答1:


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.




回答2:


Here is the simplest I could come up with. Of course, as it's simple, it's not entirely accurate or thorough. You need to read more about them to understand really how to use them and all the details.

Activity A page in your application.

Context An abstract class that contains a lot of methods needed by its subclasses: mostly Activity and Service.

Intent A link between two pages. Bundles all the details necessary to do something, send a message to the system, or go to another page of an application.




回答3:


Definitions WIKIPEDIA better information than Stackoverflow


But i believe stackoverflow gives better and precise answers for definitions. Here is a gathered information from many places [My source-Programmers Universe]





来源:https://stackoverflow.com/questions/8180180/what-is-an-activity-a-context-and-an-intent-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!