I was using this to get foreground
it is no longer working for android 5+
after doing a small online research i found that google stopped it after android 5.x
these guy here had made a solution in java
https://stackoverflow.com/questions...cesses-returns-my-application-packag/33034556
Anyone know a working way on Android 5.x or could convert that java code to B4A ?
B4X:
Sub GetPackagename As String
Dim ActMan As JavaObject
Dim R As Reflector
R.Target=R.GetContext
'Get Activity Manager Object
ActMan = R.RunMethod2("getSystemService","activity","java.lang.String")
Dim TaskInfo As JavaObject = ActMan.RunMethod("getRunningTasks",Array As Object(1))
Dim CompInfo As JavaObject = TaskInfo.RunMethodJO("get",Array As Object(0)).GetField("topActivity")
Dim PackageName As String = CompInfo.RunMethod("getPackageName",Null)
Return PackageName
End Sub
it is no longer working for android 5+
after doing a small online research i found that google stopped it after android 5.x
these guy here had made a solution in java
https://stackoverflow.com/questions...cesses-returns-my-application-packag/33034556
Anyone know a working way on Android 5.x or could convert that java code to B4A ?