Professional Documents
Culture Documents
Experiment 1.3
1. Aim:
Create Application by Using Widgets.
2. Objective:
To understand the concept of widgets and to implement the Widgets in Android
Studio.
3. Procedure:
Step 1: Create a New Project
To create a new project in Android Studio please refer to How to Create/Start a
New Project in Android Studio. We are implementing it for both Java and Kotlin
languages.
a) New*Widget+AppWidget
a) datetimewidget.java package
com.example . widgetexp33;
import android. appwidget .
AppWidgetManager; import android.
appwidget . AppWidgetProvider; import
android. content . Context; import android.
widget . RemoteViews;
Char Sequence widget Text context . get String (R. string . appwidget text) ,
// Construct the RemoteViews object
RemoteViews views new RemoteViews (context . get
PackageName ( ) R. layout. date time widget) ; views . setTextViewText
(R. i d. appwidget text, widget Text) ;
// Enter relevant
functionality for when
the first widget is
created
@Override public void onDisabled
(Context context) {
// Enter relevant
functionality for when
the last widget is
disabled
c) date_time_widget_info.xml
<?xml . 0" encoding="utf—8" ? >
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
5.Observations/Outcome:
• Learnt about Widget Functionality.
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
6. Learning Outcomes:
I successfully setup Android Studio, and created my first widget in Android Studio.