HDTutorial
EN

Playback starts YouTube’s embedded player (privacy-enhanced mode).

Simple App Widget - Android Studio Tutorial

131,267 views October 26, 2018 17:26

Watch on YouTube
ChannelCoding in Flow

Description from the creator

In this tutorial we will learn, how to create a simple home screen app widget that contains a button and opens the MainActivity when we click it.
For this we will create a widget layout, an AppWidgetProvider class and an AppWidgetProviderInfo xml file. In the AppWidgetProvider java file we will then override onUpdate and create a PendingIntent which brings us to our MainActivity. We set this intent on our widget button with help of the RemoteViews class and then update our widget with the appWidgetManager object. We repeat this process for all instances of our widget by looping through the appWidgetIds int array.
In the app widget info xml file, we define the update frequency with updatePeriodMillis, the widgetCategory, minHeight, minWidth, minResizeWidth, initialLayout and more.
Lastly we register our AppWidgetProvider in the AndroidManifest.xml file as a broadcast receiver with the APPWIDGET_UPDATE intent filter. We register our appwidget info object in the meta data tag with android.appwidget.provider.
Our widget will have a previewImage which we create with help of the Widget Preview app and it will be resizable.

Watch the whole playlist:
youtube.com/playlist?list=PLrnPJCHvNZuDCoET8jL2…

App Widget Guidelines:
developer.android.com/guide/topics/appwidgets/i…
developer.android.com/guide/practices/ui_guidel…

Example code for this part:
gist.github.com/codinginflow/5362ef5ed8a2f3f921…

____________________
💻 Find the BEST programming tutorials on TutHub:
tuthub.io

⭐ Get my MVVM Caching Course now:
codinginflow.com/caching

❗ Subscribe to the channel:
youtube.com/c/codinginflo...

📨 Subscribe to the Coding in Flow newsletter:
codinginflow.com/newsletter

❓ Join our free developer community:
discord.gg/TSnMvmc

📣 Follow Coding in Flow on other sites:
Facebook: facebook.com/codinginflow
Instagram: instagram.com/codinginflow
TikTok: tiktok.com/@codinginflow
Twitter: twitter.com/codinginflow
Github: github.com/codinginflow

💰 Business requests, sponsoring, etc.: [email protected]

About this tutorial

Coding in Flow published this 17:26 video tutorial on October 26, 2018. It has been watched 131,267 times on YouTube.

Duration
17:26
Published
October 26, 2018
Views
131,267
Likes
1,358

Tags

Share

Further reading

  • Part 1 - Simple Home Screen Widget - Coding in Flow codinginflow.com

    In this tutorial we will learn, how to create a simple home screen app widget that contains a button and opens the MainActivity when we click it. For this we will create a widget layout, an AppWidgetProvider class and a…

  • Build your first app | Android Developers developer.android.com

    This section describes how to build a simple Android app. First, you learn how to create a "Hello, World!" project with Android Studio and run it. Then, you create a new interface for the app that takes user input and s…

  • Android App Widgets Tutorial | raywenderlich.com raywenderlich.com

    The second, the topic of this tutorial, is through the implementation of App Widgets. App Widgets have been available in the Android ecosystem since version Android 1.6 (Donut). In this tutorial you’ll create an App Wid…

This tutorial in other languages