Install Guides
Kotlin
Android Permission Manifest
configuring permissions the android operating system limits access to some device functionality for end user control and privacy in order to use this functionality , configure your app to declare and request permissions from end users at runtime review permissions used by ditto ( docid\ qu1fowj 6upugzgqrduiw ) proactively check permission status to avoid unnecessary delay between granting access and ditto being able to use the feature ( docid\ qu1fowj 6upugzgqrduiw ) declar ing permissions in the android manifest android requires certain permissions to be explicitly requested by the app to access features like bluetooth low energy and wi fi aware these permissions must be declared in the app's manifest file and requested from the end user at runtime the ditto sdk's androidmanifest xml includes all of the necessary permissions for enabling its mesh network capabilities these permissions will automatically be merged with your app's permissions, so you should be aware of them androidmanifest xml \<uses permission android\ name="android permission bluetooth" android\ maxsdkversion="30" /> \<uses permission android\ name="android permission bluetooth admin" android\ maxsdkversion="30" /> \<uses permission android\ name="android permission bluetooth advertise" tools\ targetapi="s" /> \<uses permission android\ name="android permission bluetooth connect" tools\ targetapi="s" /> \<uses permission android\ name="android permission bluetooth scan" android\ usespermissionflags="neverforlocation" tools\ targetapi="s" /> \<uses permission android\ name="android permission access fine location" android\ maxsdkversion="32" /> \<uses permission android\ name="android permission access coarse location" android\ maxsdkversion="30" /> \<uses permission android\ name="android permission internet" /> \<uses permission android\ name="android permission access wifi state" /> \<uses permission android\ name="android permission access network state" /> \<uses permission android\ name="android permission change network state" /> \<uses permission android\ name="android permission change wifi multicast state" /> \<uses permission android\ name="android permission change wifi state" /> \<uses permission android\ name="android permission nearby wifi devices" android\ usespermissionflags="neverforlocation" tools\ targetapi="tiramisu" /> some of these permissions have an android\ maxsdkversion attribute which means they are not used on devices running newer versions of android this is a best practice to respect users' privacy when those permissions are not necessary however, some apps may still need to use one or more of the above permissions across more versions of android this can be accomplished by overriding the permission configuration in your app's androidmanifest xml to override any of these permission limitations in your app, do the following open the androidmanifest xml located in the app/src/main directory of your project within the same \<manifest> tag, just before the \<application> tag, add the relevant permissions you want to configure (location example) androidmanifest xml \<uses permission android\ name="android permission access fine location" tools\ remove="android\ maxsdkversion" /> \<uses permission android\ name="android permission access coarse location" tools\ remove="android\ maxsdkversion" /> note the additional tools\ remove attribute this tells the manifest merger to selectively remove the android\ maxsdkversion behavior from the associated permissions, changing them to apply to all android versions for more information, see the official https //developer android com/guide/topics/permissions/overview and https //developer android com/build/manage manifests documentation requesting permissions at runtime in addition to being declared in the manifest, some permissions need to be requested from the user at runtime to ensure your app has the required permissions for sync, use the dittosyncpermissions helper class from the ditto sdk this helper class simplifies the process of requesting end user permissions at runtime with a single method call ( ensurepermissions ) for all necessary permissions handles any errors encountered during the permissions request process using the helper to use the dittosyncpermissions helper class import the dittosyncpermissions helper class in the main activity of your app import live ditto transports dittosyncpermissions call the following in your activity or fragment's oncreate method fun requestpermissions() { val missing = dittosyncpermissions(this) missingpermissions() if (missing isnotempty()) { this requestpermissions(missing, 0) } } refresh permissions after permissions are granted on android, after granting permissions, ditto may not immediately recognize the change, causing a delay in syncing to address this, whenever a relevant permission changes, call refreshpermissions() to quickly check and start syncing with the new permissions this can be done in the onrequestpermissionsresult() activity lifecycle method private val requestpermissionlauncher = registerforactivityresult(activityresultcontracts requestmultiplepermissions()) { this ditto refreshpermissions() } override fun oncreate(savedinstancestate bundle?) { }