Widget Development


From LG G4, LG Quick Circle supports a feature whereby users can download and select a Quick Circle clock.

Developers can develop a custom clock widget for users and it can only be developed by only using Android APIs. The QCircle library does not provide APIs but the widget category for Quick Circle clock widgets needs to be specified.

In addition, the package name for the Quick Circle clock widget should not be set as ‘com.lge.*’.

The guide for developing an app widget using Android APIs is provided in the Android developer site. Please refer to the guide to learn how to develop app widgets at https://developer.android.com/guide/topics/appwidgets.


Key Implementation with Sample

The QCircle SDK includes a sample clock widget both for Android Studio and Eclipse. The sample is locate in the samples folder in the ForAnroidStudio and ForEclipse folders.

The figure below shows a circle widget sample in the QCircle SDK.


mobile_qcircle_develop_widget1.png mobile_qcircle_develop_widget2.png


Setting Widget UI

You will use a circular image as a background. Create a layout which will be a parent and set its width and height to MATCH_PARENT. All sub-UIs have to be added to this layout.
If the widget is added for Quick Circle, the layout is adjusted to fit to the Quick Circle.



Updating a Widget

The app widget provider handles broadcast events. Here, you will create an app widget provider and override onUpdate() method to update a widget view.

In onUpdate() method, a view of the widget can be updated from a RemoteViews object.

Public class SampleDigitalQuickCircleProvider extends AppWidgetProvider {
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
        super.onUpdate(context, appWidgetManager, appWidgetIds);
        for (int widgetId: appWidgetIds) {
            RemoteViews views = getView(context, widgetId);
            appWidgetManager.updateAppWidget(widgetId, views);


Declaring in the Android Manifest file

In the Android manifest file, declare the app widget provider. The receiver element allows the broadcast receiver to be known to the system. Here, the app widget provider handles broadcast events so that SampleDigitalQuickCircleProvider is registered as a receiver element.



Adding an App Widget Provider Info Metadata

Metadata for the app widget provider is defined in the app widget provider info. It is important that the widget category for Quick Circle clock is 0x200.