Integrating libProofMode Android into Audio Recorder app.

Ngenge Senior
2 min readMay 22, 2023

--

ProofMode Audio Recorder UI

A few months ago, I reported about Integrating ProofMode in Simple Camera Android, and hinted that the ProofMode team was working on making it possible to also integrate ProofMode into audio apps, well we got to work and integrated the same library into ProofMode Audio Recorder and it was a great success.

As with every app, I encountered a few difficulties/pitfalls while integrating libProofMode into the audio recorder app. Let us see the few difficulties first.

Difficulty Faced

  • POST_NOTIFICATIONS permission: Every audio recorder app needs to show a notification for the user to be able to carry out actions like pausing and stopping a current recording session and added on that, it needs to show a notification as well when audio is being played. With the usual changes in Android permissions, I had to deal with the new permission called POST_NOTIFICATIONS which is required for showing notifications on Android 13+. This was partly because I decided to make the targetSdkVerion and compileSdkVersion to be 33 since we want every Android user to be able to use the app without issues.

The Approach Used in Integration

Following the same approach in the integration with the Simple Camera Android app, I started by creating a dedicated library for proof generation, adding libProofMode Android library dependency into the library.

implementation 'org.witness:android-libproofmode:1.0.25'
def work_version = '2.8.1'
implementation "androidx.work:work-runtime-ktx:$work_version"

Next Android’s WorkManager APIs are used for the task. The worker in this case is very much the same as the one used in the Simple Camera app.

The worker gets the audio uri passed to it using its inputData and then uses it to generate the proof using the ProofMode.generateProof(Context, Uri) method from libProofMode library.

Given that the Audio Recorder app depends on saving the audio files primarily using the File APIs, we use FileProvider for getting the file Uri and as well, a method for creating the input data that is fed to the worker.

With the above code snippets, we are all set for the actual proof generation using WorkManager, so we create a static method that will use the concept from the above code snippets and create a OneTimeWorkRequest using the GenerateProofWorker worker.

For every generated audio file, a call is made to generateProofWithWorkManager and we are good to go.

What Can We Take Away from This?

If you followed through, you must have noticed that for the proof generation with libProofMode Android, the main thing required is a file Uri and so, you can integrate it into any Android app that generates files. You are not tied to using only media files, and so for any use case that requires you to preserve proof, you can go ahead and integrate it.

--

--