Más contenido relacionado Similar a Android Studio Tutorial For Beginners -2 | Android Development Tutorial | Android Training | Edureka (20) Android Studio Tutorial For Beginners -2 | Android Development Tutorial | Android Training | Edureka2. Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Agenda
✓ What is Android Studio?
✓ Android Stack
✓ Installation
✓ What is an Activity?
✓ Activity Life Cycle
✓ Event Listeners
✓ Intents
3. Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Event Listeners
Let’s look at various event listeners in an activity
4. Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Event Listeners
An event listener is an interface in the View class that contains a single callback method.
These are the tickets to capture the user interaction with your UI.
This is called when the user either touches the item when in touch mode.
onClick()
This is called when the user navigates onto or away from the item, using the navigation-keys or
trackball.
onFocusChange()
1
2
5. Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Event Listeners
onLongClick()
onKey()
onTouch()
The user either touches and holds the item when in touch mode. Say it holds the suitable "enter" key
and holds down on the trackball (for one second).
This is called when the user is focused on the item and presses or releases a hardware key on the
device.
This is called when the user performs an action qualified as a touch event, including a press, a
release, or any movement gesture on the screen (within the bounds of the item).
3
4
5
7. Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Intents
An intent is a messaging object you can use to request
an action from another app component.
➢ Methods are used to deliver intents to different
components:
• context.startActivity()
• context.startService()
• context.sendBroadcast()
8. Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Intents
An intent can carry data bundle to perform any activity
For example if an activity has to launch an email operation, we can use an
intent with ACTION_SEND.
Types of Intent:
Implicit Intent
Explicit Intent
1
2
9. Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Implicit Intent
Implicit intent is when the target component is not defined in the intent and the android
system has to evaluate the registered components based on the intent data.
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.edureka.co"));
startActivity(i);
Action Specification
10. Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Explicit Intent
Explicit intent is when an application defines the target component directly in the
intent.
Intent i = new Intent(this, ActivityTwo.class);
i.putExtra("Value1", "This is ActivityTwo ");
i.putExtra("Value2", "This value two for ActivityTwo");
startActivity(i);
Target component