Skip to content Skip to sidebar Skip to footer

How Do I Use Speechrecognizer In A Periodicworkrequest?

I'm trying to speech recognize every 15 minutes for this I'm using PeriodicWorkRequest but I get the error saying java.util.concurrent.ExecutionException: java.lang.RuntimeExceptio

Solution 1:

If you are trying to use Android Framework API to do speech recognition, that functionality is only available with the foreground activity. Based on the error it appears that you are trying to listen from background which isn't possible starting with Android 9.

Background services has gotten stricter in recent versions of Android in order to improve battery life. Previously you might be able to use a Foreground Service to maintain your process, however with features like Doze Mode, Google is restricting the use cases even further. Even if you follow the recommendations for exemption and your app had directed the user manually exempt your app from 'battery saving mode' in Settings, device manufacturers have added their own battery saving features such that a site like: https://dontkillmyapp.com/ is need to understand the current state in Android.

Most likely, any background voice activation or listening app you may have seen was with older versions of Android, or custom software by device manufacturers.

Post a Comment for "How Do I Use Speechrecognizer In A Periodicworkrequest?"