I\'m trying to develop an app that prevents a user from getting to a specified app without a password. The scenario is...
getRunningTasks()
is deprecated in Android L.
To obtain app usage statistics you can use UsageStats class from android.app.usage package.
The new App usage statistics API allows app developers to collect statistics related to usage of the applications. This API provides more detailed usage information than the deprecated getRecentTasks() method.
To use this API, you must first declare the android.permission.PACKAGE_USAGE_STATS
permission in your manifest. The user must also enable access for this app through Settings > Security > Apps with usage access
.
Here is a basic app example showing how to use App usage statistics API to let users collect statistics related to usage of the applications.