-
Notifications
You must be signed in to change notification settings - Fork 17
Initial Setup
TheBotBox edited this page May 14, 2020
·
2 revisions
First and foremost, in order to fetch a list of used applications, we need to secure USAGE ACCESS permission from the user.
For that, declare below line in the application's Manifest.xml
<uses-permission
android:name="android.permission.PACKAGE_USAGE_STATS"
tools:ignore="ProtectedPermissions" />
& to check, if the permission is granted or not, call
if (Monitor.hasUsagePermission())
else
Monitor.requestUsagePermission();
also ask for android.permission.READ_PHONE_STATE
permission if data usage is required. Neglect, if data usage in not required
if (ContextCompat.checkSelfPermission(this,
Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.READ_PHONE_STATE}, 100);
}