Offline mode in Liferay Screens lets your apps function when connectivity is unavailable or intermittent. Even though the steady march of technology makes connections more stable and prevalent, there are still plenty of places the Internet has trouble reaching. Areas with complex terrain, including cities with large buildings, often lack stable connections. Remote areas typically don’t have connections at all. Using Screens’s offline mode in your apps gives your users flexibility in these situations.
This tutorial shows you how to use offline mode in Screenlets. For an explanation of how offline mode works, see the tutorial Architecture of Offline Mode in Liferay Screens. Offline mode’s architecture is the same on iOS and Android, although its use on these platforms differs.
If you want to enable the offline mode in any of your screenlets, you must
configure the attribute
offlinePolicy. This attribute can take four possible
values. For a description of these values, see the section
Using Policies with Offline Mode
in the offline mode architecture tutorial. Note that each Screenlet behaves a
bit differently with offline mode. For specific details, see the
Screenlet reference documentation.
Under some scenarios, values stored in the local cache need to be synchronized
with the portal. For that purpose you must use the
This class is responsible for sending the information stored in the local cache
that hasn’t been sent to the portal yet.
Use the following steps to start a synchronization process:
Create an instance of the
SyncManagerclass. You must pass a
CacheManagerobject in the constructor. You can get the current cache manager using
Set the delegate property. This delegate object receives the events produced in the synchronization process. For more details on the delegate’s methods, see the API reference documentation for the
Make sure you keep a strong reference to the
SyncManagerobject while the process is running.