You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -47,18 +45,37 @@ class MainActivity : AppCompatActivity() {
47
45
super.onCreate(savedInstanceState)
48
46
setContentView(R.layout.activity_main)
49
47
setupWindowInsets()
50
-
51
48
setupIntentLauncher()
49
+
}
50
+
51
+
/**
52
+
* Initializes the activity by checking permissions, requesting the call screening role, and refreshing the call logs if the necessary permissions are granted.
53
+
*/
54
+
privatefuninit() {
52
55
checkPermissionsAndRequest()
53
56
54
57
if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.Q) {
55
58
requestCallScreeningRole()
56
59
}
57
60
58
-
refreshCallLogs()
61
+
if (ContextCompat.checkSelfPermission(
62
+
this,
63
+
Manifest.permission.READ_CALL_LOG
64
+
) ==PackageManager.PERMISSION_GRANTED
65
+
) {
66
+
refreshCallLogs()
67
+
}
68
+
}
69
+
70
+
/**
71
+
* Called when the activity comes to the foreground.
72
+
*/
73
+
overridefunonResume() {
74
+
super.onResume()
75
+
init()
59
76
}
60
77
61
-
funrefreshCallLogs() {
78
+
privatefunrefreshCallLogs() {
62
79
val blockedNumbers = getBlockedNumbers()
63
80
val callLogs = getCallLogs(this)
64
81
@@ -112,28 +129,47 @@ class MainActivity : AppCompatActivity() {
112
129
*/
113
130
privatefuncheckPermissionsAndRequest() {
114
131
val permissions =mutableListOf(
115
-
android.Manifest.permission.READ_CALL_LOG,
116
-
android.Manifest.permission.READ_PHONE_STATE
132
+
Manifest.permission.READ_CALL_LOG,
133
+
Manifest.permission.READ_PHONE_STATE,
134
+
Manifest.permission.READ_CONTACTS,
135
+
Manifest.permission.ANSWER_PHONE_CALLS,
117
136
)
118
-
119
-
if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.O) {
0 commit comments