{"id":82116,"date":"2021-07-14T09:00:06","date_gmt":"2021-07-14T03:30:06","guid":{"rendered":"https:\/\/techvidvan.com\/tutorials\/?p=82116"},"modified":"2021-07-14T09:00:06","modified_gmt":"2021-07-14T03:30:06","slug":"android-event-handling","status":"publish","type":"post","link":"https:\/\/techvidvan.com\/tutorials\/android-event-handling\/","title":{"rendered":"Android Event Handling"},"content":{"rendered":"<p>In this article, we will proceed with event handling in android. Events are the actions that take place whenever the user interacts with the UI components. Suppose, for instance, a user pressed a button, and your device flashlight got turned on.<\/p>\n<p>Did you ever think about how these actions are performed? The answer is through event handling. From this article, we will try to cover all the essential aspects of event handling.<\/p>\n<h3>What is Event Handling in Android?<\/h3>\n<p>Events are a way to check user\u2019s interactions and collect data from them. Many times, you see in your user interface elements like buttons, edit texts, radio buttons, etc.<\/p>\n<p>What happens when we touch them or press them? Our interactions with the user interface generate some actions. These actions are nothing but an event.<\/p>\n<p>Suppose, for example, whenever you press the call button in your dialer application, a call is made.<\/p>\n<p>So, event handling, in turn, means handling these interactions and performing a specific task in return. You must address all the possible events in your application. It shouldn\u2019t be the case that the user pressed a button, and the application didn\u2019t do anything in return.<\/p>\n<p>To understand how you can perform event handling, you need to know the following.<\/p>\n<ul>\n<li>Event Listeners<\/li>\n<li>Android Event Handlers<\/li>\n<li>Event Listener Registration<\/li>\n<\/ul>\n<p>Let\u2019s see each of them in detail.<\/p>\n<h3>What are Event Listeners in Android?<\/h3>\n<p>Event Listener is an interface present in the View Class. You have a single callback method for each event. This method gets triggered when the view bound with an event comes into the user\u2019s interaction.<\/p>\n<p>Below are some of the essential event listeners:<\/p>\n<table>\n<tbody>\n<tr>\n<td><b>Event Listeners<\/b><\/td>\n<td><b>Description<\/b><\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">onClick()<\/span><\/td>\n<td><span style=\"font-weight: 400\">The onClick() listener is invoked when the user presses or clicks on an element.\u00a0<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">onLongClick()<\/span><\/td>\n<td><span style=\"font-weight: 400\">The onLongClick() listener is triggered when the user long presses an element.\u00a0<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">onFocusChange()<\/span><\/td>\n<td><span style=\"font-weight: 400\">The onFocusChange() method is invoked when an element comes in focus or goes out of focus.\u00a0<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">onKey()<\/span><\/td>\n<td><span style=\"font-weight: 400\">The onKey() method is triggered when a user presses or releases a key from his keyboard.\u00a0\u00a0<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">onTouch()<\/span><\/td>\n<td><span style=\"font-weight: 400\">The onTouch() method is triggered whenever an element is touched or simply tapped.\u00a0<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">onMenuItemClick()<\/span><\/td>\n<td><span style=\"font-weight: 400\">The onMenuItemClick() method is triggered whenever the user clicks on any object in the menu list.\u00a0<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">onCreateContextMenu()<\/span><\/td>\n<td><span style=\"font-weight: 400\">The onCreateContextMenu() method is triggered whenever the menu is successfully built in the context or activity.\u00a0<\/span><\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>What are Event Handlers in Android?<\/h3>\n<p>These are the methods that have the specified action that is required to be performed. Usually, these methods are present in the event listener call-back method. It is used to define the task that has to be completed. Event listeners, when called trigger event handlers.<\/p>\n<p>Some of the commonly used event handlers are as follows:<\/p>\n<table>\n<tbody>\n<tr>\n<td><b>Event Handler<\/b><\/td>\n<td><b>Description<\/b><\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">onKeyUp()<\/span><\/td>\n<td><span style=\"font-weight: 400\">The onKeyUp() event handler is invoked to handle all the keypress events.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">onKeyDown()<\/span><\/td>\n<td><span style=\"font-weight: 400\">The onKeyDown() event handler is triggered whenever the user releases a particular key on the keyboard.\u00a0<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">onTouchEvent()<\/span><\/td>\n<td><span style=\"font-weight: 400\">The onTouchEvent() event handler is invoked whenever a touch event occurs.\u00a0<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">onTrackballEvent()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Whenever a trackball event occurs then onTrackballEvent() is triggered.\u00a0<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">onFocusChange()<\/span><\/td>\n<td><span style=\"font-weight: 400\">The onFocusChange() event handler is triggered whenever an element focuses or goes out of focus.\u00a0<\/span><\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>Event Listener Registration in Android<\/h3>\n<p>Event listener registration is the process of mapping the event listener with the respective event handler. This is a crucial step as the event can only be triggered when the listener is called.<\/p>\n<p>Whenever the event occurs, then the handler should perform the task. Therefore, both need to be synced properly.<\/p>\n<p>Event Listener Registration is done in three ways that are described as follows:<\/p>\n<p>1. First, you can directly register the event listeners using the activity\u2019s XML file. For example, in buttons, we can now provide the onClick attribute to register the event listener.<\/p>\n<p>2. You can register the event listener by writing it in an Activity class that extends properties from the Listener Class.<\/p>\n<p>3. The last method is by dynamically setting the listener on the element. For example, you can see beloow<\/p>\n<p><strong>Code Example:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">\/\/you can register onClick() event \n\/\/in the following manner\nyour_button.setOnClickListener {\n\n\/\/you can specify the task to be performed here.\n            Toast.makeText(this@MainActivity, \"Your Button Pressed\", Toast.LENGTH_LONG).show()\n        }<\/pre>\n<h4>Touch Mode<\/h4>\n<p>Usually, you can find many ways to interact with your application. It may be through buttons, screen, gestures, hardware or even volume buttons. By Touch mode, we mean to give access to the application to respond to the touch events.<\/p>\n<p>One pervasive example is your screenshots. Whenever you wish to take a screenshot, you use your three fingers to drag on the screen. Another ubiquitous example is your image zooming. You can double-tap or use your two fingers to zoom in on the image.<\/p>\n<p>To check whether your application responds to touch events or not, you can call the<strong> isInTouchMode().<\/strong><\/p>\n<h4>Focus Mode<\/h4>\n<p>Focus is a basic mode for any application. This mode shows which element is currently in focus. It helps the user to take care of the interactions he makes.<\/p>\n<p>One typical example is when the user inputs data in the EditText element, then it gets highlighted.<\/p>\n<p>To check whether an element is focusable or not, you can call the <strong>isFocusable()<\/strong> method. You can even alter the element focus by changing the value in the <strong>setFocusable()<\/strong> method. You can call the isFocusableInTouchMode() to know whether or not the element is focusable in touch mode.<\/p>\n<h3>Implementation of Android Event Handling<\/h3>\n<p>So, after gathering a little knowledge about event handling, we are ready to see a demo. In this demo, you will see how you can handle onClick() and onLongClick() events. For this task, you can use buttons in the layout and then register the events to them.<\/p>\n<p>Below are the simple but crucial steps which you need to follow to build the application.<\/p>\n<p><strong>1:<\/strong> Launch your Android Studio.<\/p>\n<p><strong>2:<\/strong> Select Create a New Project.<\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/07\/Event_App_Building_1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-82764\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/07\/Event_App_Building_1.png\" alt=\"Android Event Handling\" width=\"972\" height=\"732\" \/><\/a><\/p>\n<p><strong>3:<\/strong> Select Empty Activity and proceed.<\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/07\/Event_App_Building_2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-82765\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/07\/Event_App_Building_2.png\" alt=\"Android Event App Building\" width=\"1252\" height=\"928\" \/><\/a><\/p>\n<p><strong>4:<\/strong> Enter your application name. In my case, it\u2019s \u201cTechVidvanEvents.\u201d Next, select Kotlin from the dropdown. For the API level, select API 22 for now.<\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/07\/Event_App_Building_3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-82766\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/07\/Event_App_Building_3.png\" alt=\"Android Event App\" width=\"1236\" height=\"924\" \/><\/a><\/p>\n<p><strong>5:<\/strong> Now go to res &#8212;&gt; layout &#8212;-&gt; and open activity_main.xml. Now here, you need to add two buttons. You can paste the below code in your activity_main.xml file.<\/p>\n<p><strong>Code: activity_main.xml<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\n&lt;androidx.constraintlayout.widget.ConstraintLayout\n    xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\"\n    xmlns:app=\"http:\/\/schemas.android.com\/apk\/res-auto\"\n    xmlns:tools=\"http:\/\/schemas.android.com\/tools\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\n    tools:context=\".MainActivity\"&gt;\n\n    &lt;TextView\n        android:id=\"@+id\/title\"\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"wrap_content\"\n        android:text=\"TechVidvan\"\n        android:textColor=\"#4CAF50\"\n        android:textSize=\"40sp\"\n        app:layout_constraintVertical_bias=\".07\"\n        app:layout_constraintBottom_toBottomOf=\"parent\"\n        app:layout_constraintLeft_toLeftOf=\"parent\"\n        app:layout_constraintRight_toRightOf=\"parent\"\n        app:layout_constraintTop_toTopOf=\"parent\" \/&gt;\n\n    &lt;Button\n        android:id=\"@+id\/button_1\"\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"wrap_content\"\n        android:text=\"Press Me\"\n        app:layout_constraintVertical_bias=\".15\"\n        app:layout_constraintBottom_toBottomOf=\"parent\"\n        app:layout_constraintEnd_toEndOf=\"parent\"\n        app:layout_constraintStart_toStartOf=\"parent\"\n        app:layout_constraintTop_toBottomOf=\"@+id\/title\" \/&gt;\n\n    &lt;Button\n        android:id=\"@+id\/button_2\"\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"wrap_content\"\n        android:text=\"Long Press Me\"\n        app:layout_constraintVertical_bias=\".15\"\n        app:layout_constraintBottom_toBottomOf=\"parent\"\n        app:layout_constraintEnd_toEndOf=\"parent\"\n        app:layout_constraintStart_toStartOf=\"parent\"\n        app:layout_constraintTop_toBottomOf=\"@+id\/button_1\" \/&gt;\n\n&lt;\/androidx.constraintlayout.widget.ConstraintLayout&gt;<\/pre>\n<p><strong>6:<\/strong> After editing your XML file, you need to register event listeners in your Main Activity file. Paste the below code in your Main Activity file.<\/p>\n<p><strong>Code: MainActivity.kt<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">package com.techvidvan.techvidvanevents\n\nimport android.os.Bundle\nimport android.widget.Button\nimport android.widget.Toast\nimport androidx.appcompat.app.AppCompatActivity\n\nclass MainActivity : AppCompatActivity()\n{\n    \/\/Declaring variables for both the buttons\n    lateinit var press_button:Button\n    lateinit var long_press_button:Button\n\n    override fun onCreate(savedInstanceState: Bundle?)\n    {\n        super.onCreate(savedInstanceState)\n        setContentView(R.layout.activity_main)\n\n        \/\/binding the varibale with our\n        \/\/buttons in layout\n        press_button = findViewById(R.id.button_1)\n        long_press_button = findViewById(R.id.button_2)\n\n        \/\/registering event listener with our buttons\n\n        press_button.setOnClickListener {\n            Toast.makeText(this@MainActivity, \"Button 1 Pressed\", Toast.LENGTH_LONG).show()\n        }\n\n\n        long_press_button.setOnLongClickListener {\n            Toast.makeText(this@MainActivity, \"Button 2 Pressed Long\", Toast.LENGTH_LONG).show()\n            \/\/return true when button is long pressed\n            true\n        }\n    }\n}<\/pre>\n<p>So after your application is built successfully, you can check it. The application would look like below.<\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/07\/App_Output_1-1.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-82768\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/07\/App_Output_1-1.jpg\" alt=\"Android Event Handling\" width=\"1080\" height=\"2280\" \/><\/a><\/p>\n<p>When you press the \u201cPress me button,\u201d you get a Toast saying Button 1 Pressed.<\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/07\/App_Output_2-1.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-82769\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/07\/App_Output_2-1.jpg\" alt=\"Android Event App\" width=\"1080\" height=\"2280\" \/><\/a><\/p>\n<p>Whereas, when you press the \u201cLong press Me button,\u201d you get a Toast message saying that Button 2 Long Pressed.<\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/07\/App_Output_3-1.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-82770\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/07\/App_Output_3-1.jpg\" alt=\"Event Handler in Android\" width=\"1080\" height=\"2280\" \/><\/a><\/p>\n<h3>Summary<\/h3>\n<p>Through this article, you understood what an event is in android and when do they occur. Then, you saw several types of event listeners and also the event handlers.<\/p>\n<p>Moving forth, you came across how you can register an event listener. Finally, you saw an app demo to implement the concepts.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this article, we will proceed with event handling in android. Events are the actions that take place whenever the user interacts with the UI components. Suppose, for instance, a user pressed a button,&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":82762,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2791],"tags":[3785,3786,3787],"class_list":["post-82116","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-android","tag-android-event-handling","tag-event-handlers-in-android","tag-event-listeners-in-android"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Android Event Handling - TechVidvan<\/title>\n<meta name=\"description\" content=\"Learn about Event Handling in Android. Learn about the types of event listeners and event handlers. Learn how to register an event listener.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/techvidvan.com\/tutorials\/android-event-handling\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Android Event Handling - TechVidvan\" \/>\n<meta property=\"og:description\" content=\"Learn about Event Handling in Android. Learn about the types of event listeners and event handlers. Learn how to register an event listener.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/techvidvan.com\/tutorials\/android-event-handling\/\" \/>\n<meta property=\"og:site_name\" content=\"TechVidvan\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/TechVidvan\/\" \/>\n<meta property=\"article:published_time\" content=\"2021-07-14T03:30:06+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/06\/Android-Event-Handling.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"TechVidvan Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:site\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"TechVidvan Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Android Event Handling - TechVidvan","description":"Learn about Event Handling in Android. Learn about the types of event listeners and event handlers. Learn how to register an event listener.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/techvidvan.com\/tutorials\/android-event-handling\/","og_locale":"en_US","og_type":"article","og_title":"Android Event Handling - TechVidvan","og_description":"Learn about Event Handling in Android. Learn about the types of event listeners and event handlers. Learn how to register an event listener.","og_url":"https:\/\/techvidvan.com\/tutorials\/android-event-handling\/","og_site_name":"TechVidvan","article_publisher":"https:\/\/www.facebook.com\/TechVidvan\/","article_published_time":"2021-07-14T03:30:06+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/06\/Android-Event-Handling.jpg","type":"image\/jpeg"}],"author":"TechVidvan Team","twitter_card":"summary_large_image","twitter_creator":"@vidvantech","twitter_site":"@vidvantech","twitter_misc":{"Written by":"TechVidvan Team","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/techvidvan.com\/tutorials\/android-event-handling\/#article","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/android-event-handling\/"},"author":{"name":"TechVidvan Team","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22"},"headline":"Android Event Handling","datePublished":"2021-07-14T03:30:06+00:00","mainEntityOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/android-event-handling\/"},"wordCount":1135,"commentCount":0,"publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/android-event-handling\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/06\/Android-Event-Handling.jpg","keywords":["Android Event Handling","Event Handlers in Android","Event Listeners in Android"],"articleSection":["Android Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/techvidvan.com\/tutorials\/android-event-handling\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/techvidvan.com\/tutorials\/android-event-handling\/","url":"https:\/\/techvidvan.com\/tutorials\/android-event-handling\/","name":"Android Event Handling - TechVidvan","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/#website"},"primaryImageOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/android-event-handling\/#primaryimage"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/android-event-handling\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/06\/Android-Event-Handling.jpg","datePublished":"2021-07-14T03:30:06+00:00","description":"Learn about Event Handling in Android. Learn about the types of event listeners and event handlers. Learn how to register an event listener.","breadcrumb":{"@id":"https:\/\/techvidvan.com\/tutorials\/android-event-handling\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/techvidvan.com\/tutorials\/android-event-handling\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/android-event-handling\/#primaryimage","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/06\/Android-Event-Handling.jpg","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/06\/Android-Event-Handling.jpg","width":1200,"height":628,"caption":"Android Event Handling"},{"@type":"BreadcrumbList","@id":"https:\/\/techvidvan.com\/tutorials\/android-event-handling\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/techvidvan.com\/tutorials\/"},{"@type":"ListItem","position":2,"name":"Android Event Handling"}]},{"@type":"WebSite","@id":"https:\/\/techvidvan.com\/tutorials\/#website","url":"https:\/\/techvidvan.com\/tutorials\/","name":"TechVidvan Blogs","description":"","publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/techvidvan.com\/tutorials\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/techvidvan.com\/tutorials\/#organization","name":"TechVidvan","url":"https:\/\/techvidvan.com\/tutorials\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","width":200,"height":50,"caption":"TechVidvan"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/TechVidvan\/","https:\/\/x.com\/vidvantech"]},{"@type":"Person","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22","name":"TechVidvan Team","description":"The TechVidvan Team delivers practical, beginner-friendly tutorials on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our experts are here to help you upskill and excel in today\u2019s tech industry."}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/82116","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/comments?post=82116"}],"version-history":[{"count":0,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/82116\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media\/82762"}],"wp:attachment":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media?parent=82116"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/categories?post=82116"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/tags?post=82116"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}