UNIT-2 Activities, Fragments and Intents
UNIT-2 Activities, Fragments and Intents
• Implicit Intent
• Implicit Intent doesn't specify the component. In such case, intent
provides information of available components provided by the system that
is to be invoked.
• For example, you may write the following code to view the
webpage.
Syntax:
Intent intent=new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("http://www.example.com"));
startActivity(intent);
Types of Android Intents
• Explicit Intent
• Explicit Intent specifies the
component. In such case, intent
provides the external class to be
invoked.
• Syntax:
Intent i = new Intent(getApplicationContext
(), ActivityTwo.class);
startActivity(i);
Intent Structure
• The primary pieces of information in an intent are: action -- The
general action to be performed, such as ACTION_VIEW,
ACTION_EDIT, ACTION_MAIN, etc. data -- The data to operate on,
such as a person record in the contacts database, expressed as a Uri.
Intent Structure
• Each fragment has its own life cycle methods that is affected by activity life cycle because
fragments are embedded in activity.