What is Activity and Intent in Android? What is the difference between Activity and Intent?

Asked 21-Jan-2018
Viewed 898 times

1

What is Activity and Intent in Android? What is the difference between Activity and Intent?


1 Answer


0

An activity in an android application is the screen which opens first to the user and with which the user interacts. an android application may contain several activities. 

to make an activity in android you need to extend your class from parent class which is ACTIVITY class. for example, to make an activity you need to write - 

class MainActivity extends Activity {

........

}

an intent in android is the way to pass the message to activities. an activity can also be used to start the service or broadcast the message. 

An intent is of two types 

  1. Implicit Intent - Implicit intent can be used to start the application such as maps or youtube from your application.
  2. Explicit Intent - explicit intent can be used to pass the messages within your activity.

To write an intent - 

Intent intent = new Intent(this, someactivity.class);

startActivity(intent);