Simple App Widget – Android Studio Tutorial

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 w

It's only fair to share...Tweet about this on TwitterShare on FacebookShare on TumblrShare on Google+Digg thisShare on LinkedInPin on PinterestShare on VKShare on RedditPrint this pageEmail this to someone
Flattr the authorShare on StumbleUponShare on YummlyBuffer this page

Leave a Reply

Your email address will not be published. Required fields are marked *