@qusaieilouti99/call-manager 0.1.70 → 0.1.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -996,7 +996,35 @@ object CallEngine {
|
|
|
996
996
|
startForegroundService() // Just restart the service with updated info
|
|
997
997
|
}
|
|
998
998
|
|
|
999
|
+
private fun isMainActivityInForeground(): Boolean {
|
|
1000
|
+
val context = requireContext()
|
|
1001
|
+
val activityManager = context.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
|
|
1002
|
+
|
|
1003
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
1004
|
+
val tasks = activityManager.getAppTasks()
|
|
1005
|
+
if (tasks.isNotEmpty()) {
|
|
1006
|
+
val taskInfo = tasks[0].taskInfo
|
|
1007
|
+
return taskInfo.topActivity?.className?.contains("MainActivity") == true
|
|
1008
|
+
}
|
|
1009
|
+
} else {
|
|
1010
|
+
@Suppress("DEPRECATION")
|
|
1011
|
+
val tasks = activityManager.getRunningTasks(1)
|
|
1012
|
+
if (tasks.isNotEmpty()) {
|
|
1013
|
+
return tasks[0].topActivity?.className?.contains("MainActivity") == true
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
return false
|
|
1017
|
+
}
|
|
1018
|
+
|
|
999
1019
|
private fun bringAppToForeground() {
|
|
1020
|
+
// Check if MainActivity is already in foreground
|
|
1021
|
+
if (isMainActivityInForeground()) {
|
|
1022
|
+
Log.d(TAG, "MainActivity is already in foreground, skipping bringAppToForeground()")
|
|
1023
|
+
return
|
|
1024
|
+
}
|
|
1025
|
+
|
|
1026
|
+
Log.d(TAG, "MainActivity is not in foreground, bringing to foreground")
|
|
1027
|
+
|
|
1000
1028
|
val context = requireContext()
|
|
1001
1029
|
val packageName = context.packageName
|
|
1002
1030
|
val launchIntent = context.packageManager.getLaunchIntentForPackage(packageName)
|