v24
Powered By GitBook
Android Lib Overview
Monterosa / Interaction Cloud (M/IC) was previously known as LViS. As such, you will find API documentation using the term.
The Android lib allows Android developers to connect natively to the platform.

Add to project

Add to the /build.gradle
1
allprojects {
2
repositories {
3
maven {
4
url "s3://fankit.android.s3.amazonaws.com"
5
credentials(AwsCredentials) {
6
accessKey "AKIAILV2UEEPQRSY726A"
7
secretKey "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"
8
}
9
}
10
}
11
}
Copied!
Add to the app/build.gradle. Please see changelog for latest LViS versions.
1
implementation 'co.monterosa.fankit:lvis:23.0.1'
Copied!

Dependencies

The LViS library internally depends on Enmasse library and its dependencies and all of them are fetched automatically when you add LViS library to client project.
1
implementation 'co.monterosa.fankit:enmasse:23.0.0'
Copied!

LViS library structure

There are 4 basic blocks that you need to work with:
    LViS - is an entry point to work with LViS lib
    Project - is an entity that represents an 'LViS Project'
    Event - is an entity that represents an 'LViS Event'
    Elements - are entities that represent 'LViS Elements'

How to use

You can override default TRUE values if needed.
1
void setWssSupport(boolean useWss);
2
void setReloadEventsHistorySupport(boolean reload);
Copied!
LViS needs to store its values internally. So you need to set a path to your internal or external storage:
1
void setCacheDir(String cacheDirPath);
Copied!
LViS needs to be initialized with projectUuid and host
1
void setProject(String host, String projectUuid);
Copied!
It's possible to load App Setup before connecting to LViS
1
void loadSettings(new ResultCallback() {
2
@Override
3
public void onSuccess(Object result) {
4
}
5
@Override
6
public void onFailed(String reason) {
7
}
8
});
Copied!
To open LViS and subscribe to its changes:
1
void open(new LViSObserver() {
2
@Override
3
public void onInit(boolean reinit) {
4
Project project = LViS.getInstance().getProject();
5
}
6
@Override
7
public void onScheduleReinit(long backoffMillis) {
8
}
9
@Override
10
public void onEventPublished(Event event) {
11
}
12
@Override
13
public void onSettingsChanged() {
14
}
15
});
Copied!
To subscribe to an event:
1
void subscribe(event, new ResultCallback() {
2
@Override
3
public void onSuccess(){}
4
@Override
5
public void onFailed(String reason) {}});
Copied!
After you've subscribed to an event you can get all event elements:
1
List<Element> allElements = event.getHistory();
Copied!
And you can listen to an event's changes:
1
event.registerCallback(new Event.Callback() {
2
@Override
3
public void onUpdated() {
4
}
5
@Override
6
public void onStateChanged(Event.State state) {
7
}
8
@Override
9
public void onElementPublished(Element element) {
10
}
11
@Override
12
public void onElementRevoked(Element element) {
13
}
14
});
Copied!
You can listen to each element's changes. For example, to listen to a Regular poll's changes:
1
if (element instanceof RegularPoll){
2
RegularPoll regularPoll = (RegularPoll) element;
3
regularPoll.registerCallback(new RegularPoll.Callback() {
4
@Override
5
public void onStateChanged(RegularPoll.State state) {
6
}
7
@Override
8
public void onResults() {
9
}
10
@Override
11
public void onVote() {
12
}
13
});
14
}
Copied!
To unsubscribe from an event:
1
void unsubscribe(event);
Copied!
To log in with your userId and signature
1
User.login(String userId, long timestamp, String signature, ResultCallback resultCallback)
Copied!
After you've done with LViS you need to close it to clean all resources:
1
void close()
Copied!
If you need to manage logs:
1
Log.enableTags(String[] tags) //Supported tags are {LViS.TAG, Enmasse.TAG, TransportApi.TAG}
2
Log.registerCallback(Callback callback)
Copied!

Changelog

Last modified 1yr ago