Configure the Widget by adding the following Settings to your values/strings.xml:
<resources>
<string name="widget_domain" translatable="false">YOUR_DOMAIN_ID</string>
<string name="widget_feed_hash" translatable="false">YOUR_FEED_HASH</string>
<string name="widget_launchactivity" translatable="false">YOUR_LAUNCH_ACTIVITY</string>
<!-- only needed, if the Feed is secured with a Secret -->
<string name="widget_feed_secret" translatable="false">YOUR_FEED_SECRET</string>
<!-- this Parameter can be obtained from 3Q nexx or nexxOMNIA -->
<string name="widget_app" translatable="false">YOUR_APP_ID</string>
<!-- only needed for android 12+ -->
<string name="widget_description">Widget Description</string>
</resources>
Handle the System Intents by adding a receiver to src/main/AndroidManifest.xml:
Prepare the necessary Image Assets (Icon and Preview PNGs) and place them under src/main/res/drawable/
Handling Intent
Once a User clicks on any Item of the Widget, the App is called directly (if the receiver has been configured correctly).
The App now is responsable to collect all necessary details in order to navigate to the Target of this Intent:
...@OverridepublicvoidonCreate(Bundle savedInstanceState) {Intent intent =getIntent();if (intent !=null) {String action =intent.getAction();//make sure, this Intent comes from the Widgetif(action.equals("tv.nexx.android.widget.OPEN"){//the Widget sends all available Item Identifiers in the Extra Bundle for easy access.appDoNavigate(intent.getStringExtra("streamtype"),intent.getStringExtra("itemID")); } }}
The available Item Identifiers are:
itemID
itemHash
globalID
refnr
slug
link (if configured in nexxOMNIA)
domainID
streamtype
Enhanced Methods
It is possible to update/refresh/reconfigure all Widget Instances from your App directly with the following Methods:
importtv.nexx.android.widget.Widget;importtv.nexx.android.widget.WidgetConfiguration;publicclassMainActivity { @OverrideprotectedvoidonCreate(Bundle savedInstanceState) {...Widget widget =newWidget();//simple force all Widget Instances to refresh the Feedwidget.updateWidgets(this.getContext());//update the Configuration and refresh the FeedWidgetConfiguration config=newWidgetConfiguration(newHashMap<String,Object>() {{ put("language","es"); put("feedUpdateInterval",30); }} );widget.updateConfiguration(this.getContext(),config); }}
For a detailed Overview of the Meaning of the given Configuration, please take a look here: