> For the complete documentation index, see [llms.txt](https://docs.mluvii.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.mluvii.com/en/for-it-specialists/mobile-sdk/android.md).

# Android

Mluvii provides a framework for integration with your application(Android 5.0+, lower version are not supported due to the low version of WebView). The code provided by us enables you to:

* initiate a webview with a widget with your company data

```
MluviiLibrary.getMluviiWebView(Context, server_name, company_id, tenant_id, widget_name, language);
```

* notification on change of widget status

```
 MluviiLibrary.setStatusOnlineCallback(() ->{});
 MluviiLibrary.setStatusBusyCallback(() ->{});
 MluviiLibrary.setStatusOfflineCallback(() ->{});
```

* open chat

```
 MluviiLibrary.runChat();
```

* close the chat and load a page with widget

```
MluviiLibrary.setCloseChatFunc(() ->{});
```

* add own handling for opening URL in chat

```
MluviiLibrary.setUrlCallbackFunc(new MluviiLibrary.UrlCallback(){

            @Override
            public Void call() throws Exception{
                Log.d("MLUVII_URL_CALLBACK","Test url: "+this.url);
                return null;
            }
        });
```

* adding customized parameters - when adding customized parameters, you must first set them in the Administration Interface, see [Application](/en/for-administrators/tenant-management/settings/application.md)
* if the user of your mobile application has to perform some action (click on a button, etc.) after opening the WebView, **we recomment to add a delay** e.g. 2 seconds. This will ensure **flawless saving of values to existing session parameters**.
* it is necessary to first set parameters and then call MluviiLibrary.runChat()

```
MluviiLibrary.addCustomData("'param_name'", "'param_value'");
```

* To allow tracking of clients(chat history) you need to allow cookies in webView

```
if (android.os.Build.VERSION.SDK_INT >= 21) {   
  CookieManager.getInstance().setAcceptThirdPartyCookies(mluviiWebView, true);
} else {
  CookieManager.getInstance().setAcceptCookie(true);
} 
```

{% hint style="danger" %}
***If you want to use a video, you need to enable your camera and microphone in your application.***
{% endhint %}

You need to allow permissions in manifest

```
    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
    <uses-permission android:name="android.permission.CAMERA" />
```

In Android 6.0+ you have to add in app check for permissions. This can be called when needed and code should look like this:

```
if (ContextCompat.checkSelfPermission(this,
                Manifest.permission.CAMERA)
                != PackageManager.PERMISSION_GRANTED) {

            if (ActivityCompat.shouldShowRequestPermissionRationale(this,
                    Manifest.permission.CAMERA)) {
                //Can add explanation why do you need this specific permissions
                ActivityCompat.requestPermissions(this,
                        new String[]{Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO},
                        REQUEST_CAMERA_PERMISSION);

            } else {
                // No explanation needed; request the permission
                ActivityCompat.requestPermissions(this,
                        new String[]{Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO},
                        REQUEST_CAMERA_PERMISSION);
            }
        }
```

## Android Library

{% embed url="<https://github.com/mluvii/MluviiAndroidLib>" %}

### Sample Code

You can find it [here](https://github.com/Mluvii/MluviiAndroidLib/blob/master/WebviewApp/app/src/main/java/mluviipoc/mluvii/com/webviewapp/MainActivity.java).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.mluvii.com/en/for-it-specialists/mobile-sdk/android.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
