{"id":84226,"date":"2021-08-28T09:00:34","date_gmt":"2021-08-28T03:30:34","guid":{"rendered":"https:\/\/techvidvan.com\/tutorials\/?p=84226"},"modified":"2024-08-05T22:01:19","modified_gmt":"2024-08-05T16:31:19","slug":"android-widgets","status":"publish","type":"post","link":"https:\/\/techvidvan.com\/tutorials\/android-widgets\/","title":{"rendered":"Android Widgets"},"content":{"rendered":"<p>Android Widgets are an exciting feature that enhances user interaction by allowing actions to be performed directly from the home screen. Instead of constantly searching for an application to perform routine tasks, you can use the widgets available on your home screen for quick access.<\/p>\n<p>Imagine checking the weather; you don\u2019t need to open the weather app every time. A weather widget can provide real-time updates right on your home screen, making your life easier and more efficient. Widgets are a powerful tool for improving user experience and engagement with your app. So, let\u2019s dive in and explore the world of Android Widgets!<\/p>\n<h3>About Android Widgets<\/h3>\n<p>Android Widgets are a part of the UI element used to customize your device\u2019s home screen. Android Widget allows its users to easily access the application from the widget present on their home screen. Along with this, they can even position the widget on the home screen wherever they want. They can also resize the widgets depending on their needs.<\/p>\n<p>Let\u2019s see how you can design your widget using XML.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">&lt;LinearLayout xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\"\r\n    android:id=\"@+id\/widget_layout\"\r\n    android:layout_width=\"match_parent\"\r\n    android:layout_height=\"match_parent\"\r\n    android:background=\"@drawable\/background\"\r\n    android:gravity=\"center\"\r\n    android:orientation=\"vertical\"\r\n    android:padding=\"@dimen\/widget_margin\"&gt;\r\n\r\n    &lt;TextView style=\"@style\/WidgetButtonVerticalSpace\" \/&gt;\r\n\r\n    &lt;TextView\r\n        android:id=\"@+id\/appwidget_text\"\r\n        style=\"@style\/WidgetTextView.Big\" \/&gt;\r\n\r\n    &lt;TextView\r\n        style=\"@style\/WidgetTextView\"\r\n        android:text=\"Your Widget\" \/&gt;\r\n\r\n    &lt;TextView style=\"@style\/WidgetButtonVerticalSpace\" \/&gt;\r\n\r\n    &lt;LinearLayout\r\n        android:layout_width=\"match_parent\"\r\n        android:layout_height=\"wrap_content\"\r\n        android:orientation=\"horizontal\"&gt;\r\n\r\n        &lt;TextView style=\"@style\/WidgetButtonHorizontalSpace\" \/&gt;\r\n\r\n        &lt;LinearLayout\r\n            android:id=\"@+id\/ristretto_button\"\r\n            style=\"@style\/myWidgetButton\" &gt;\r\n\r\n            &lt;ImageView\r\n                style=\"@style\/WidgetButtonImage\"\r\n                android:src=\"@drawable\/ic_airplane\" \/&gt;\r\n            &lt;TextView\r\n                style=\"@style\/WidgetButtonText\"\r\n                android:text=\"Airplane\" \/&gt;\r\n\r\n        &lt;\/LinearLayout&gt;\r\n\r\n        &lt;TextView style=\"@style\/WidgetButtonHorizontalSpace\" \/&gt;\r\n\r\n        &lt;LinearLayout\r\n            android:id=\"@+id\/espresso_button\"\r\n            style=\"@style\/myWidgetButton\"&gt;\r\n\r\n            &lt;ImageView\r\n                style=\"@style\/WidgetButtonImage\"\r\n                android:src=\"@drawable\/ic_wifi\" \/&gt;\r\n            &lt;TextView\r\n                style=\"@style\/WidgetButtonText\"\r\n                android:text=\"Wifi\" \/&gt;\r\n\r\n        &lt;\/LinearLayout&gt;\r\n\r\n        &lt;TextView style=\"@style\/WidgetButtonHorizontalSpace\" \/&gt;\r\n\r\n        &lt;LinearLayout\r\n            android:id=\"@+id\/long_button\"\r\n            style=\"@style\/myWidgetButton\" &gt;\r\n\r\n            &lt;ImageView\r\n                style=\"@style\/WidgetButtonImage\"\r\n                android:src=\"@drawable\/ic_mobile\" \/&gt;\r\n            &lt;TextView\r\n                style=\"@style\/WidgetButtonText\"\r\n                android:text=\"Data\" \/&gt;\r\n\r\n        &lt;\/LinearLayout&gt;\r\n\r\n        &lt;TextView style=\"@style\/WidgetButtonHorizontalSpace\" \/&gt;\r\n\r\n    &lt;\/LinearLayout&gt;\r\n\r\n    &lt;TextView style=\"@style\/WidgetButtonVerticalSpace\" \/&gt;\r\n\r\n    &lt;TextView\r\n        android:id=\"@+id\/coffee_quote\"\r\n        style=\"@style\/WidgetQuote\" \/&gt;\r\n\r\n&lt;\/LinearLayout&gt;\r\n<\/pre>\n<h3>Components of Android Widget<\/h3>\n<p>Android Widget is made of three components that are classified as follows:<\/p>\n<p><strong>1. AppWidgetProviderInfo:<\/strong> AppWidgetProviderInfo is an instance of the widget containing the widget details like its layout, updates, etc. It specifies the metadata for the widget, including its size, update frequency, and initial layout. This information is essential for defining how the widget behaves and appears on the user&#8217;s home screen.<\/p>\n<p><strong>2. AppWidgetProvider:<\/strong> AppWidgetProvider provides the facility of paginating over a collection of an undefined number of objects. It acts as a bridge between the widget&#8217;s functionality and the Android system, handling widget updates and interactions. It ensures the widget&#8217;s data is refreshed and responds to user actions appropriately.<\/p>\n<p><strong>3. ViewLayout:<\/strong> ViewLayout is used to define the layout of your widgets. It determines how the elements within the widget are arranged and displayed, such as buttons, text views, and images. A well-designed layout enhances the widget&#8217;s usability and visual appeal, making it more engaging for users.<\/p>\n<h3>Methods in Android Widget<\/h3>\n<p>The methods present in the Android Widget allow you to customize your widgets and add more functionalities.<\/p>\n<table>\n<tbody>\n<tr>\n<td><b>Method Name<\/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;\">onDelete()<\/span><\/td>\n<td><span style=\"font-weight: 400;\">The onDelete() method is invoked whenever an AppWidgetProvider is deleted.\u00a0\u00a0<\/span><\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">onEnabled()<\/span><\/td>\n<td><span style=\"font-weight: 400;\">The onEnabled() method is invoked whenever an AppWidgetProvider is created.\u00a0<\/span><\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">onDisabled()<\/span><\/td>\n<td><span style=\"font-weight: 400;\">The onDisabled() method is invoked whenever the last detected AppWidgetProvider is deleted.<\/span><\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">onReceive()<\/span><\/td>\n<td><span style=\"font-weight: 400;\">The onReceive() method is invoked whenever the system needs to distribute calls to the various classes.\u00a0<\/span><\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>Limitations of Android Widget<\/h3>\n<p>Even though widgets are quite helpful, they do have some limitations or restrictions. Let\u2019s see a few of them listed below:<\/p>\n<h4>Gestures<\/h4>\n<p>Widgets don\u2019t support all kinds of gestures. They only allow its users to click and drag the widget. If your app involves some gestures to make an action, that won\u2019t be happening through widgets. For that, you need to open your app and make that gesture.<\/p>\n<h4>Elements<\/h4>\n<p>You can\u2019t access all elements of your app through your widget itself. There are some restrictions of the UI elements that you can keep in your widget.<\/p>\n<h3>Adding Widget to your Android application<\/h3>\n<p>Now, let\u2019s see how you can add widgets to your application in three simple steps.<\/p>\n<p><strong>1. XML definition file:<\/strong> You need to create an XML definition file in the res\/values\/ to initialize the widget.<\/p>\n<p><strong>2. Kotlin file:<\/strong> To initialize the behavior of your widget, you need to create a Kotlin file in your main package.<\/p>\n<p><strong>3. Layout FIle:<\/strong> The Layout file is optional, but you can design and style your widgets.<\/p>\n<h3>Types of Android Widgets<\/h3>\n<p>In general, we have four types of Android Widgets, but with the coming up of Android 12, the android widgets have been revamped a lot.<br \/>\nLet\u2019s see the several types of Android Widgets, along with a brief description of each.<\/p>\n<h4>1. Information Widgets<\/h4>\n<p>The information widgets are usually used to update users about any activity or provide some essential information. The most common information widgets are clock, weather, and news widgets.<\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/Android_Widgets-normal-image01.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-84337\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/Android_Widgets-normal-image01.jpg\" alt=\"Information Widgets\" width=\"400\" height=\"144\" \/><\/a><\/p>\n<h4>2. Collection Widgets<\/h4>\n<p>The collection widgets provide you with a collection of similar types of elements to scroll over vertically. One such example is the widget of email applications.<\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/Android_Widgets-normal-image02.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-84338\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/Android_Widgets-normal-image02.jpg\" alt=\"Collection Widgets\" width=\"460\" height=\"500\" \/><\/a><\/p>\n<h4>3. Control Widgets<\/h4>\n<p>The control widgets are used to perform a particular action without opening every application. One such example is your flashlight, WIFI, GPS, Mobile Data. You need not go to settings to find out each of them and then perform the action, and you can directly perform them using the control widget.<\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/Android_Widgets-normal-image03.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-84339\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/Android_Widgets-normal-image03.jpg\" alt=\"Control Widgets\" width=\"440\" height=\"150\" \/><\/a><\/p>\n<h4>4. Hybrid Widgets<\/h4>\n<p>The Hybrid Widgets are a combination of the above-discussed widgets and can be used to provide multiple functionalities. One such example is your Music Player, which gives you the information of the current playing songs and also allows you to control the music by providing play and pause buttons.<\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/Android_Widgets-normal-image04.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-84340\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/Android_Widgets-normal-image04.jpg\" alt=\"Hybrid Widgets\" width=\"440\" height=\"150\" \/><\/a><\/p>\n<h3>Implementation of Android Widgets<\/h3>\n<p>Now, let\u2019s see how we can use the above concepts to build our widgets. For this, you need to follow every step clearly and then look at the comments to understand what each part does appropriately.<\/p>\n<p><strong>1:<\/strong> Start your Android and click on Create a new Project.<\/p>\n<p><strong>2:<\/strong> Now, select an empty activity and provide an application name.<\/p>\n<p><strong>3:<\/strong> Create a new android resource directory called XML in the res folder. The XML folder would contain an info file containing the metadata of our widget.<\/p>\n<p><strong>Code: app\/res\/my_widget_info.xml<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\r\n&lt;appwidget-provider xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\"\r\n    android:minWidth=\"180dp\"\r\n    android:minHeight=\"110dp\"\r\n    android:updatePeriodMillis=\"86400000\"\r\n    android:previewImage=\"@drawable\/background\"\r\n    android:initialLayout=\"@layout\/tech_vidvan_widget\"\r\n    android:resizeMode=\"horizontal|vertical\"\r\n    android:widgetCategory=\"home_screen\"\r\n    android:initialKeyguardLayout=\"@layout\/tech_vidvan_widget\"&gt;\r\n&lt;\/appwidget-provider&gt;\r\n<\/pre>\n<p><strong>4:<\/strong> After finishing up with Step 2, open your AndroidManifest.xml file and add the below receiver.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">&lt;receiver android:name=\".MyWidgetClass\"&gt;\r\n           &lt;intent-filter&gt;\r\n               &lt;action android:name=\"android.appwidget.action.APPWIDGET_UPDATE\"\/&gt;\r\n           &lt;\/intent-filter&gt;\r\n\r\n           &lt;meta-data\r\n               android:name=\"android.appwidget.provider\"\r\n               android:resource=\"@xml\/my_widget_info\"\/&gt;\r\n       &lt;\/receiver&gt;\r\n<\/pre>\n<p>After adding the above receiver, your code will appear as follows:<\/p>\n<p><strong>Code: AndroidManifest.xml<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\r\n&lt;manifest xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\"\r\n    package=\"com.techvidvan.techvidvanwidget\"&gt;\r\n\r\n    &lt;application\r\n        android:allowBackup=\"true\"\r\n        android:icon=\"@mipmap\/ic_launcher\"\r\n        android:label=\"@string\/app_name\"\r\n        android:roundIcon=\"@mipmap\/ic_launcher_round\"\r\n        android:supportsRtl=\"true\"\r\n        android:theme=\"@style\/Theme.TechVidvanWidget\"&gt;\r\n\r\n        &lt;receiver android:name=\".MyWidgetClass\"&gt;\r\n            &lt;intent-filter&gt;\r\n                &lt;action android:name=\"android.appwidget.action.APPWIDGET_UPDATE\"\/&gt;\r\n            &lt;\/intent-filter&gt;\r\n\r\n            &lt;meta-data\r\n                android:name=\"android.appwidget.provider\"\r\n                android:resource=\"@xml\/my_widget_info\"\/&gt;\r\n        &lt;\/receiver&gt;\r\n\r\n        &lt;activity android:name=\".MainActivity\"&gt;\r\n            &lt;intent-filter&gt;\r\n                &lt;action android:name=\"android.intent.action.MAIN\" \/&gt;\r\n\r\n                &lt;category android:name=\"android.intent.category.LAUNCHER\" \/&gt;\r\n            &lt;\/intent-filter&gt;\r\n        &lt;\/activity&gt;\r\n\r\n\r\n    &lt;\/application&gt;\r\n\r\n&lt;\/manifest&gt;<\/pre>\n<p><strong>5:<\/strong> Now, you need to create a custom layout for your widget, for which you can go to res\/values\/layouts and create a new layout resource file.<\/p>\n<p><strong>Code: tech_vidvan_widget.xml<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">&lt;LinearLayout xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\"\r\n    android:id=\"@+id\/widget_layout\"\r\n    android:layout_width=\"match_parent\"\r\n    android:layout_height=\"match_parent\"\r\n    android:background=\"@drawable\/background\"\r\n    android:gravity=\"center\"\r\n    android:orientation=\"vertical\"\r\n    android:padding=\"@dimen\/widget_margin\"&gt;\r\n\r\n    &lt;TextView style=\"@style\/WidgetButtonVerticalSpace\" \/&gt;\r\n\r\n    &lt;TextView\r\n        android:id=\"@+id\/appwidget_text\"\r\n        style=\"@style\/WidgetTextView.Big\" \/&gt;\r\n\r\n    &lt;TextView\r\n        style=\"@style\/WidgetTextView\"\r\n        android:text=\"Your Widget\" \/&gt;\r\n\r\n    &lt;TextView style=\"@style\/WidgetButtonVerticalSpace\" \/&gt;\r\n\r\n    &lt;LinearLayout\r\n        android:layout_width=\"match_parent\"\r\n        android:layout_height=\"wrap_content\"\r\n        android:orientation=\"horizontal\"&gt;\r\n\r\n        &lt;TextView style=\"@style\/WidgetButtonHorizontalSpace\" \/&gt;\r\n\r\n        &lt;LinearLayout\r\n            android:id=\"@+id\/ristretto_button\"\r\n            style=\"@style\/myWidgetButton\" &gt;\r\n\r\n            &lt;ImageView\r\n                style=\"@style\/WidgetButtonImage\"\r\n                android:src=\"@drawable\/ic_airplane\" \/&gt;\r\n            &lt;TextView\r\n                style=\"@style\/WidgetButtonText\"\r\n                android:text=\"Airplane\" \/&gt;\r\n\r\n        &lt;\/LinearLayout&gt;\r\n\r\n        &lt;TextView style=\"@style\/WidgetButtonHorizontalSpace\" \/&gt;\r\n\r\n        &lt;LinearLayout\r\n            android:id=\"@+id\/espresso_button\"\r\n            style=\"@style\/myWidgetButton\"&gt;\r\n\r\n            &lt;ImageView\r\n                style=\"@style\/WidgetButtonImage\"\r\n                android:src=\"@drawable\/ic_wifi\" \/&gt;\r\n            &lt;TextView\r\n                style=\"@style\/WidgetButtonText\"\r\n                android:text=\"Wifi\" \/&gt;\r\n\r\n        &lt;\/LinearLayout&gt;\r\n\r\n        &lt;TextView style=\"@style\/WidgetButtonHorizontalSpace\" \/&gt;\r\n\r\n        &lt;LinearLayout\r\n            android:id=\"@+id\/long_button\"\r\n            style=\"@style\/myWidgetButton\" &gt;\r\n\r\n            &lt;ImageView\r\n                style=\"@style\/WidgetButtonImage\"\r\n                android:src=\"@drawable\/ic_mobile\" \/&gt;\r\n            &lt;TextView\r\n                style=\"@style\/WidgetButtonText\"\r\n                android:text=\"Data\" \/&gt;\r\n\r\n        &lt;\/LinearLayout&gt;\r\n\r\n        &lt;TextView style=\"@style\/WidgetButtonHorizontalSpace\" \/&gt;\r\n\r\n    &lt;\/LinearLayout&gt;\r\n\r\n    &lt;TextView style=\"@style\/WidgetButtonVerticalSpace\" \/&gt;\r\n\r\n    &lt;TextView\r\n        android:id=\"@+id\/coffee_quote\"\r\n        style=\"@style\/WidgetQuote\" \/&gt;\r\n\r\n&lt;\/LinearLayout&gt;\r\n<\/pre>\n<p><strong>6:<\/strong> Now, you need to create a class called MyWidgetClass.kt and then paste in the below code.<\/p>\n<p><strong>Code: MyWidgetClass.kt<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">package com.techvidvan.techvidvanwidget\r\n\r\nimport android.appwidget.AppWidgetManager\r\nimport android.appwidget.AppWidgetProvider\r\nimport android.content.Context\r\nimport android.widget.RemoteViews\r\n\r\nclass MyWidgetClass : AppWidgetProvider() {\r\n\r\n    override fun onUpdate(context: Context, appWidgetManager: AppWidgetManager, appWidgetIds: IntArray) {\r\n        \/\/ Updating all the widgets\r\n        for (appWidgetId in appWidgetIds) {\r\n            updateAppWidget(context, appWidgetManager, appWidgetId)\r\n        }\r\n    }\r\n\r\n    override fun onEnabled(context: Context) {\r\n        \/\/ Describing the functionality when the first widget is created\r\n    }\r\n\r\n    override fun onDisabled(context: Context) {\r\n        \/\/ Describing the functionality when the last widget is disabled\r\n    }\r\n\r\n    companion object {\r\n\r\n        internal fun updateAppWidget(\r\n            context: Context, appWidgetManager: AppWidgetManager,\r\n            appWidgetId: Int\r\n        ) {\r\n\r\n            val widgetText = \"TechVidvanWidget\"\r\n            \/\/ Creating the RemoteViews object\r\n            val views = RemoteViews(context.packageName, R.layout.tech_vidvan_widget)\r\n            views.setTextViewText(R.id.appwidget_text, widgetText)\r\n\r\n            \/\/ Use the widget manager to update the widget\r\n            appWidgetManager.updateAppWidget(appWidgetId, views)\r\n        }\r\n    }\r\n}\r\n<\/pre>\n<p><strong>7:<\/strong> Now, leave your activity_main.xml and MainActivity.kt file as it is and rebuild the project.<\/p>\n<p>After performing all the above steps, you must test your application on your device and notice how the widget appears in the machine.<\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/App_Output_1-1.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-84341\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/App_Output_1-1.jpg\" alt=\"Android Widgets\" width=\"1080\" height=\"2280\" \/><\/a><\/p>\n<p>You can see that at the bottom in the widgets section, the TechVidvanWidget is available. Now just click on it and drag it and resize it as follows.<\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/App_Output_2-1.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-84342\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/App_Output_2-1.jpg\" alt=\"Android Widgets Example\" width=\"1080\" height=\"2280\" \/><\/a><\/p>\n<h3>Summary<\/h3>\n<p>Through this article, you came across a fascinating topic called Android Widgets. You saw how you could make the user\u2019s task easier and customize his home screen using Android widgets. Then you came across several components that build up the Android Widget. You saw its methods and the various types of widgets present. Finally, you saw how to implement android widgets in your app.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Android Widgets are an exciting feature that enhances user interaction by allowing actions to be performed directly from the home screen. Instead of constantly searching for an application to perform routine tasks, you can&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":84335,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2791],"tags":[4149,4150,4151,4152,4153,4154],"class_list":["post-84226","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-android","tag-android-widgets","tag-components-of-android-widget","tag-implementation-of-android-widgets","tag-limitations-of-android-widget","tag-methods-in-android-widget","tag-types-of-android-widgets"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Android Widgets - TechVidvan<\/title>\n<meta name=\"description\" content=\"Learn about Android Widgets, its components and implementation. See its methods and various types of widgets present in Android.\" \/>\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-widgets\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Android Widgets - TechVidvan\" \/>\n<meta property=\"og:description\" content=\"Learn about Android Widgets, its components and implementation. See its methods and various types of widgets present in Android.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/techvidvan.com\/tutorials\/android-widgets\/\" \/>\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-08-28T03:30:34+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-08-05T16:31:19+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/08\/Android_Widgets.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 Widgets - TechVidvan","description":"Learn about Android Widgets, its components and implementation. See its methods and various types of widgets present in Android.","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-widgets\/","og_locale":"en_US","og_type":"article","og_title":"Android Widgets - TechVidvan","og_description":"Learn about Android Widgets, its components and implementation. See its methods and various types of widgets present in Android.","og_url":"https:\/\/techvidvan.com\/tutorials\/android-widgets\/","og_site_name":"TechVidvan","article_publisher":"https:\/\/www.facebook.com\/TechVidvan\/","article_published_time":"2021-08-28T03:30:34+00:00","article_modified_time":"2024-08-05T16:31:19+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/08\/Android_Widgets.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-widgets\/#article","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/android-widgets\/"},"author":{"name":"TechVidvan Team","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22"},"headline":"Android Widgets","datePublished":"2021-08-28T03:30:34+00:00","dateModified":"2024-08-05T16:31:19+00:00","mainEntityOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/android-widgets\/"},"wordCount":1116,"commentCount":0,"publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/android-widgets\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/08\/Android_Widgets.jpg","keywords":["Android Widgets","Components of Android Widget","Implementation of Android Widgets","Limitations of Android Widget","Methods in Android Widget","Types of Android Widgets"],"articleSection":["Android Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/techvidvan.com\/tutorials\/android-widgets\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/techvidvan.com\/tutorials\/android-widgets\/","url":"https:\/\/techvidvan.com\/tutorials\/android-widgets\/","name":"Android Widgets - TechVidvan","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/#website"},"primaryImageOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/android-widgets\/#primaryimage"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/android-widgets\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/08\/Android_Widgets.jpg","datePublished":"2021-08-28T03:30:34+00:00","dateModified":"2024-08-05T16:31:19+00:00","description":"Learn about Android Widgets, its components and implementation. See its methods and various types of widgets present in Android.","breadcrumb":{"@id":"https:\/\/techvidvan.com\/tutorials\/android-widgets\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/techvidvan.com\/tutorials\/android-widgets\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/android-widgets\/#primaryimage","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/08\/Android_Widgets.jpg","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/08\/Android_Widgets.jpg","width":1200,"height":628,"caption":"Android Widgets"},{"@type":"BreadcrumbList","@id":"https:\/\/techvidvan.com\/tutorials\/android-widgets\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/techvidvan.com\/tutorials\/"},{"@type":"ListItem","position":2,"name":"Android Widgets"}]},{"@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\/84226","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=84226"}],"version-history":[{"count":2,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/84226\/revisions"}],"predecessor-version":[{"id":447610,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/84226\/revisions\/447610"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media\/84335"}],"wp:attachment":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media?parent=84226"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/categories?post=84226"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/tags?post=84226"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}