Escolar Documentos
Profissional Documentos
Cultura Documentos
Android - Home
Android - Overview
Android - Environment Setup
Android - Architecture
Android - Application Components
Android - Hello World Example
Android - Resources
Android - Activities
Android - Services
Android - Broadcast Receivers
Android - Content Providers
Android - Fragments
Android - Intents/Filters
Android - UI Layouts
Android - UI Controls
Android - Event Handling
Android - Styles and Themes
Android - Custom Components
Android - ProgressBar
Android - Push Notification
Android - RenderScript
Android - RSS Reader
Android - Screen Cast
Android - SDK Manager
Android - Sensors
Android - Session Management
Android - Shared Preferences
Android - SIP Protocol
Android - Spelling Checker
Android - SQLite Database
Android - Support Library
Android - Testing
Android - Text to Speech
Android - TextureView
Previous Page
Next Page
A widget is a small gadget or control of your android application placed on the home screen. Widgets can be
very handy as they allow you to put your favourite applications on your home screen in order to quickly access
them. You have probably seen some common widgets, such as music widget, weather widget, clock widget e.t.c
Widgets could be of many types such as information widgets, collection widgets, control widgets and hybrid
widgets. Android provides us a complete framework to develop our own widgets.
android:initialLayout="@layout/activity_main">
</appwidget-provider>
In the end you have to call an update method updateAppWidget() of the AppWidgetManager class. Its syntax is
appWidgetManager.updateAppWidget(currentWidgetId,views);
A part from the updateAppWidget method, there are other methods defined in this class to manipulate widgets.
They are as follows
Sr.No
onDisabled(Context context)
onEnabled(Context context)
Example
Here is an example demonstrating the use of application Widget. It creates a basic widget applications that will
open this current website in the browser.
To experiment with this example, you need to run this on an actual device on which internet is running.
Steps
Description
You will use Android studio to create an Android application under a package
com.example.sairamkrishna.myapplication. While creating this project, make sure you Target SDK and
Compile With at the latest version of Android SDK to use higher levels of APIs.
Create a new folder and xml file under res/xml/mywidget.xml to add respective XML components
Run the application and choose a running android device and install the application on it and verify the results.
Let's try to run your application. I assume you have connected your actual Android Mobile device with your
computer. To run the app from Android studio, open one of your project's activity files and click Run
icon from
the tool bar. Before starting your application, Android studio will display following window to select an option
where you want to run your Android application.
Select your mobile device as an option and then check your mobile device which will display your default screen
Go to your widget section and add your created widget to the desktop or home screen. It would look something
like this
Now just tap on the widget button that appears, to launch the browser. But before that please make sure that you
are connected to the internet. After pressing the button , the following screen would appear
Note. By just changing the url in the java file, your widget will open your desired website in the browser.
Previous Page
Next Page
Advertisements
Write for us
FAQ's
Helping
Contact