 Hello everyone, today we are going to discuss on the topic event handling in Android. Let us see the learning outcome of this topic. At the end of the session, students will be able to describe event handling in Android application together with an Android Studio based example project. First, we will see about event. Events are a useful way to collect data about a user's interaction with interactive components of applications like button presses or screen touch etc. The Android framework maintains an event queue as first in first out basis. You can capture these events in your program and take appropriate action as per requirements. Android event management, which is very important for the developer to develop an app. There are three concepts related to Android event management. First one, event listeners. An event listener is an interface in the view class that contains a single callback method. These methods will be called by the Android framework when the view to which the listener has been registered is triggered by user interaction with the atom in the user interface. Event listeners registration. Event registration is the process by which an event handler gets registered with an event listener so that the handler is called when the event listener fires the event. Event handlers. When an event handler and we have registered an event listener for the event, the event listener calls the event handlers, which is the method that actually handlers the event. These three important Android event management is required for the developer to develop an app. Now we will see the types of event handlers because the user has to use different event handlers as per the requirements to develop a mobile app. So first is on click listener. This event listener is called when a user clicks on any user interface element like button, text or image. On click event handler is used to handle this event. Suppose for example the user has to write a code for the button. So user has to use the listener interface as an on click listener interface. Then on long click listener. This method is called when a user clicks on any user interface element for a long time or hold user interface element for a few seconds. On long click event handler is used to handle this listener. On focus change listener. This method is called when user interface element or a widget loses its focus. Simply user navigates forward and on focus change event handler is used to handle this listener. Here the developer has to use these concepts in developing an app. When the user has to use suppose a text field and user has to change the focus from one text field to the second text field. In that case he has to use on focus change listener. Suppose user has to press a button for a long or hold for a few seconds. Then he has to use the listener as on long click listener. These are the very important listeners which the mobile developer to develop the mobile apps. More listeners on key listeners. This method is called when a user presses a key on keyboard that is on key event handler is used to handle this event. Because when user presses any key on the keyboard similarly the listener works on on key listener interface. Then on touch listener. This method is called when user coaches any user interface element on the screen like press or release a button. On touch event handler is used to handle this listener. Now check the changed listener interface definition for a callback to be invoked when the check the state of a component button changed. These are again very important event listeners which is used for mobile developer to develop the app. Once you define a listener the associated component will work as event handlers. So what are the event handlers? We will see the concept. First one on key round. This method is called when the new key event occurs. On key up this method is called when a key up event occurs. On track ball event this method is called when a track ball motion event occurs. On touch event this method is called when a touch screen motion event occurs. On focus change this method is called when the view gains or losses focus. So here the user has to use all these handlers as per the associated event listeners. So event listeners and event handlers work together to perform action. Here one example you will see that is the hello world example. Here there are two buttons one is a small font and another is a large font. Now if you try to click on two buttons one by one and you will see that font of the hello world text will change. Which happens because registered click event handler method is being called against each click event. So here some steps we have to follow how we will make use of separate listener class to register and captures click event. Similar way you can implement your listener for any other required event type. Here hope you will create an anonymous implementation of the listener and will be useful if each class is applied to a single control only. And you have advantage to pass arguments to event handler. In this approach event handler methods can access private data of activity no reference is needed to call to activity. If you apply the handler to more than one control you would have to cut and paste the code for the handler. And if the code for the handler is long it makes the code harder to maintain. So here we will see the steps. First one you will use Android Studio ID to create an Android application and name it as my application under a package com.example.myApplication as explained in the hello world example. Modify source mean activity.java file to add click event listener and handlers for the two buttons defined. So event listener handlers we have seen in the previous two slides. So we have to use those for these two buttons defined. Third modify the default content of layout activity main.example file to include Android user interface control. Here no need to declare the default string constants because Android Studio takes care default constants. And finally run the application to launch Android Emulator and verify the result of the changes done in the application. So these are the steps which is required to run that hello world example. Now we will see some event handling associated with checkbox. Here we use event object as a checkbox change. Event listener on checkbox change listener. Event handler on checkbox change. So these handler and listener will work together to perform with the checkbox. This is the example. Here when the user clicks the checkbox the on click change event will occur. And on change listener will also work with the on check listener interface. Similarly when we work with the event handling associated with radio group again we have to handling management that is event listener on check change listener and event handler is on check change. When we work with the radio buttons so these two work together to perform the action. So in this example when the user clicks on radio button under the radio group the on check listener will work with the handler as on check handler. Now pause the video for a while and answer the question. Question is and dash is an interface in the view class that contains a single call base method. Single call back method. The answer is event listener. Just we have seen that event listener is an interface in the view class which is used to a single call back method. Second question. A dash is used when one want to execute a task on the event of the click. And the answer is on click listener because on click listener is the listener or we can say it is an interface in the view class which is used when one want to execute a particular task on the event of the click. For example if you click on the radio button if you click on the check box or if you click on the text box so this listener will work together with that component. These are the references for this topic. Thank you.