Android - Getting started
Sample App
https://github.com/wemap/livemap-android-sdk-sample
Usage
- Add the following dependency in your
build.gradle
:
implementation 'com.getwemap:livemap-sdk'
Versions are listed on the maven repo: https://repo1.maven.org/maven2/com/getwemap/livemap-sdk/
- a. Add the
LivemapView
in your layout
<com.getwemap.livemap.sdk.LivemapView
android:id="@+id/livemap"
android:layout_width="match_parent"
android:layout_height="match_parent"
wemap:emmid="19158"
wemap:token="GUHTU6TYAWWQHUSR5Z5JZNMXX" />
- b. Or create the view dynamically
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
LivemapOptions livemapOptions = new LivemapOptions();
livemapOptions.emmid = 19158;
livemapOptions.token = "GUHTU6TYAWWQHUSR5Z5JZNMXX";
mLivemapView = new LivemapView(this, livemapOptions);
setContentView(mLivemapView);
}
- Test it :)
SDK Methods and Events
First, get the Livemap
object in your Activity
/Fragment
:
public class LivemapMethodsActivity extends AppCompatActivity
implements OnLivemapReadyCallback {
private LivemapView mLivemapView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_livemap);
mLivemapView = findViewById(R.id.livemap);
mLivemapView.getLivemapAsync(this);
}
@Override
public void onLivemapReady(Livemap livemap) {
// Your code here.
}
}
Then, you can use our methods from the Livemap documentation.
You can also have a look to our two samples LivemapMethodsActivity.java and LivemapEventsActivity.java
Note: in order to deal with user permissions dynamically, please call these two methods from your Activity
/Fragment
:
@Override
public void onRequestPermissionsResult(int requestCode,
@NonNull String[] permissions,
@NonNull int[] grantResults) {
mLivemapView.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
mLivemapView.onActivityResult(requestCode, resultCode, data);
}