MemfaultCloud Android
The MemfaultCloud library provides convenience APIs for mobile applications that interact with Memfault's web services.
Sample App
The sample/
directory contains a very basic Android application that
demonstrates the functionality of this library. Feedback from user interactions
is logged to LogCat and displayed as Toasts.
Before building the app, make sure to update the Project key in
SampleViewModel.kt
.
Adding the SDK to your project
Add the library to your application's build.gradle
:
dependencies {
implementation 'com.memfault.cloud:cloud-android:2.0.5'
}
The artifact is hosted on the
Maven Central Repository, so you may
need to add mavenCentral()
to your list of project repositories. See the
sample app's root build.gradle
for an example.
repositories {
mavenCentral()
google()
}
Initialization
The
MemfaultCloud
class is the main entry point for the MemfaultCloud
SDK. We recommend creating
only one MemfaultCloud
instance and using it across your entire application.
Getting the latest release
Use the memfaultCloud.getLatestRelease API to query Memfault's services to find if a new update is available for a device.
Uploading Chunks
The Memfault Firmware SDK packetizes data to be sent to Memfault's cloud into "chunks". See this tutorial for details.
Once you have established sending chunks from your device to the Android app, use the ChunkSender API to upload these chunks to Memfault.
Acknowledgements
We used Square's excellent OKHTTP library as a reference when implementing this SDK's HTTP code.