Memfault Cloud
class MemfaultCloud
The Memfault SDK entrypoint.
Initialization
We recommend creating only one instance of MemfaultCloud and using it across your entire application. Use the Builder to create an instance.
Kotlin:
val memfault = MemfaultCloud.Builder()
.setApiKey(PROJECT_KEY)
.build()Content copied to clipboard
Java:
final Memfault memfault = new Memfault.Builder()
.setApiKey(PROJECT_KEY)
.build();Content copied to clipboard
To find your PROJECT_KEY, log in to [https://app.memfault.com/] and navigate to Settings.
Getting the Latest Release
You can check to see whether there's a new update for a particular device with MemfaultCloud.getLatestRelease:
Kotlin:
memfaultCloud.getLatestRelease(deviceInfo, callback = object : GetLatestReleaseCallback {
override fun onUpdateAvailable(otaPackage: MemfaultOtaPackage) {
// There's a new software package
}
override fun onUpToDate() {
// Device is up to date, nothing to do!
}
override fun onError(e: Exception) {
// There was an error; handle it here
}
})Content copied to clipboard
Java:
final GetLatestReleaseCallback callback = new GetLatestReleaseCallback() {
@Override
public void onUpdateAvailable(@NonNull MemfaultOtaPackage otaPackage) {
// There's a new software package
}
@Override
public void onUpToDate() {
// Device is up to date, nothing to do!
}
@Override
public void onError(@NonNull Exception e) {
// There was an error; handle it here
}
};
memfaultCloud.getLatestRelease(callback);Content copied to clipboard
Permissions
The SDK requires several permissions in order to implement all functionality. Callers should check for these permissions and, if necessary, request them[https://developer.android.com/training/permissions/requesting] from the user.