Obtain usage time data from other applications

I want to know how from my Ionic application how long the user has used other applications, such as Facebook, etc.
On Android I have seen something like ‘Digital Wellness’ found in settings, but I don’t know how I can take information from there.