How to detect app removed from the recent list?

I want stop the service when user removes the application from the recent list. Yes, you can either do that using stopWithTask flag as true for Service in Manifest file. Example: <service android:enabled=”true” android:name=”.MyService” android:exported=”false” android:stopWithTask=”true” /> OR If you need event of application being removed from recent list, and do something before stopping service, … Read more

How to check if “android.permission.PACKAGE_USAGE_STATS” permission is given?

Special permissions that are granted by the user in the system settings (usage stats access, notification access, …) are handled by AppOpsManager, which was added in Android 4.4. Note that besides user granting you access in the system settings you typically need a permission in the Android manifest (or some component), without that your app … Read more