I'm trying to build a widget for my flash light app. I'm using android studio. I right clicked layout and chose widget>app widget and it created required files.
here's light_widget_info.xml which i edited
<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:minWidth="40dp"
android:minHeight="40dp"
android:updatePeriodMillis="86400000"
android:previewImage="@drawable/example_appwidget_preview"
android:initialLayout="@layout/light_widget"
android:resizeMode="horizontal|vertical"
android:widgetCategory="home_screen"
android:initialKeyguardLayout="@layout/light_widget"></appwidget-provider>
I get
"The following classes couldn't be found
-include (fix build path)"
error.
Create a new folder named
xml
inres
folder, and put the xml file there...Widget - XML file should be in xml folder It should point to mainActivity which in layout folder(something like res/layout/activity_main.xml)
Also you should declare AppWidgetProvider class in your manifest file as follows
Here is a step by step example you can refer