detect activity

madru

Active Member
Licensed User
Longtime User
I am are writing a classroom application, where the teacher will have the possibility to monitor verify etc. what the student is doing.
It is implemented in that way that the teacher can open a TCP session to the tablet (running a server as a service) and take control of the device......

the question is now how I can detect which activity is active, I can hold a variable for each activity and use that one in the service module but I think that is the wrong approach - any change to query the active activitys name or similar?


THX

M
 

Kevin

Well-Known Member
Licensed User
Longtime User
I don't know if this is exactly what you are after. The problem here is that you would need to already know what activities are in the project. If you are looking to get the name of the active activity (and the possible activity names are unknown) then I don't know what the solution would be.

Using the code below as a starter, you could iterate through all possible activities and narrow it down to which one is active.

B4X:
If IsPaused(Main) = False Then
   ToastMessageShow("Activity 'Main' is active", True)
End If
If IsPaused(Activity2) = False Then
   ToastMessageShow("Activity 'Activity2' is active", True)
End If
If IsPaused(Activity3) = False Then
   ToastMessageShow("Activity 'Activity3' is active", True)
End If
 
Upvote 0
Top