Hi,
RSSmartWidgets is used in my AirWidgets app.
It lets your app hosts widgets as views so you can use it in your application (launcher, widget selection, etc)
For an example see here: https://play.google.com/store/apps/details?id=com.rootsoft.airwidgetslite
Documentation:
RSSmartWidgets
Author: XverhelstX
Version: 1
How to use:
You should call startlistening to start listening for updates on the given hostview, and stoplistening to stop.
Always remove your hostview when stopping or closing your application.
There are methods in it that you shouldn't use or doesn't have any purpose, because that is suited to my app.
Kind regards,
Tomas
RSSmartWidgets is used in my AirWidgets app.
It lets your app hosts widgets as views so you can use it in your application (launcher, widget selection, etc)
For an example see here: https://play.google.com/store/apps/details?id=com.rootsoft.airwidgetslite
Documentation:
RSSmartWidgets
Author: XverhelstX
Version: 1
- RSSmartWidgets
Methods:- AddView (Panel As PanelWrapper, hostView As AppWidgetHostView, left As Int, top As Int)
Adds a view to the given panel.
view:
hostView: - AppWidget (appWidgetId As Int, info As AppWidgetProviderInfo)
- CreateSmartWidget (appWidgetId As Int) As AppWidgetHostView
Creates a smart widget. - CreateSmartWidget2 (widgetPackage As String) As AppWidgetHostView
Creates a smart widget. - Initialize (EventName As String, HostId As Int)
Initializes the Smart Widgets.
EventName:
HostId: The hostId is a number of your choosing that should be internally
unique to your app (that is, you don't need to worry about collisions
with other apps on the system). It's designed for cases where you
want two unique AppWidgetHosts inside of the same application, so the
system can optimize and only send updates to actively listening hosts. - RemoveWidget (hostView As AppWidgetHostView)
Remove view from the layout and host. - SelectWidget
Let user pick a widget from the list of installed AppWidgets - StartListening
Start listening to pending intents from the widgets. - StopListening
Stops listening to pending intents from the widgets. - getAppWidgetInfo (appWidgetId As Int) As AppWidgetProviderInfo
Get the available info about the AppWidget.
Returns A appWidgetId. If the appWidgetId has not been bound to a provider yet, or you don't have access to that appWidgetId, null is returned.
- AppToStart As String
- AppWidgetId As Int [read only]
Gets the app widgets id. - HostId As Int
Gets or sets the host id. - HostView As AppWidgetHostView [read only]
- InstalledProviders As List [read only]
Return a list of the AppWidget providers that are currently installed. - OnLongClickListener As AppWidgetHostView [write only]
- RunningAppPackageNames As List [read only]
- AddView (Panel As PanelWrapper, hostView As AppWidgetHostView, left As Int, top As Int)
- RSWidgetHostView
Methods:- BringToFront
- Initialize (EventName As String)
Initializes this widget host view. - Invalidate
- Invalidate2 (arg0 As Rect)
- Invalidate3 (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
- IsInitialized As Boolean
- RemoveView
- RequestFocus As Boolean
- SendToBack
- SetBackgroundImage (arg0 As Bitmap)
- SetLayout (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
- AppWidgetId As Int [read only]
Gets this view app widget id. - AppWidgetInfo As AppWidgetProviderInfo [read only]
Gets the app widget provider info. - Background As Drawable
- Color As Int [write only]
- Enabled As Boolean
- Height As Int
- Left As Int
- Tag As Object
- Top As Int
- Visible As Boolean
- Width As Int
- RSWidgetProviderInfo
Methods:- Initialize (EventName As String)
Initializes this Widget Provider Info. - IsInitialized As Boolean
- AutoAdvanceViewId As Int [read only]
The view id of the AppWidget subview which should be auto-advanced by the widget's host. - Icon As Int [read only]
The icon to display for this AppWidget in the AppWidget picker. If not supplied in the xml, the application icon will be used. - InitialKeyguardLayout As Int [read only]
The resource id of the initial layout for this AppWidget when it is displayed on keyguard. - InitialLayout As Int [read only]
The resource id of the initial layout for this AppWidget. This should be displayed until the RemoteViews for the AppWidget is available. - Label As String [read only]
The label to display to the user in the AppWidget picker. If not supplied in the xml, the application label will be used. - MinHeight As Int [read only]
The default height of the widget when added to a host, in dp.
The widget will get at least this height, and will often be given more, depending on the host. - MinResizeHeight As Int [read only]
Minimum height (in dp) which the widget can be resized to.
This field has no effect if it is greater than minHeight or if vertical resizing isn't enabled (see resizeMode). - MinResizeWidth As Int [read only]
Minimum width (in dp) which the widget can be resized to.
This field has no effect if it is greater than minWidth or if horizontal resizing isn't enabled (see resizeMode). - MinWidth As Int [read only]
The default height of the widget when added to a host, in dp.
The widget will get at least this width, and will often be given more, depending on the host. - PackageName As String [read only]
The packagename of the widget. - PreviewImage As Int [read only]
A preview of what the AppWidget will look like after it's configured.
If not supplied, the AppWidget's icon will be used. - ResizeMode As Int [read only]
The rules by which a widget can be resized. - UpdatePeriodMillis As Int [read only]
How often, in milliseconds, that this AppWidget wants to be updated.
The AppWidget manager may place a limit on how often a AppWidget is updated. - WidgetCategory As Int [read only]
Determines whether this widget can be displayed on the home screen, the keyguard, or both.
A widget which is displayed on both needs to ensure that it follows the design guidelines for both widget classes.
This can be achieved by querying the AppWidget options in its widget provider's update method.
- Initialize (EventName As String)
How to use:
B4X:
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
'Declaration of libraries
Dim SmartWidgets As RSSmartWidgets
End Sub
Sub CreateSmartWidget(id As Int)
SmartWidgets.Initialize("SmartWidgets", id)
SmartWidgets.SelectWidget
End Sub
' ! --------------- ! WIDGET EVENTS ! --------------- ! '
'After a widgets has been selected, this gets called.
Sub SmartWidgets_WidgetCreated (HostId As Int, HostView As Object, WidgetId As Int, WidgetInfo As Object)
End Sub
Sub SmartWidgets_BackPressed (WidgetId As Int)
Log("Back pressed")
End Sub
You should call startlistening to start listening for updates on the given hostview, and stoplistening to stop.
Always remove your hostview when stopping or closing your application.
There are methods in it that you shouldn't use or doesn't have any purpose, because that is suited to my app.
Kind regards,
Tomas