Is there any way to get current running foreground application (package) for all available OS?

前端 未结 1 1142
攒了一身酷
攒了一身酷 2021-01-05 22:05

I know, too many questions already raised on this topic but, that are not supported in all OS / devices

Question

  1. Is there any way to
相关标签:
1条回答
  • 2021-01-05 22:25

    You can have 2 approaches to this that may be acceptable, otherwise you are probably out of luck.

    1) Make your app the "launcher" app. Users will then be interacting with your app in order to launch apps in general. Notification based launches and other types of interactions you may not be able to track, but I have not tried.

    2) Make your app "pretend" to be a launcher app. After it launches, it displays a launcher type screen. You then have to handle attempts to press "home" by checking if your app is in the background and bringing it into foreground if it is. This is not an easy task - it's likely you will have bugs, etc. but it seems possible (I only know that determining if your app is "in the background" can be tricky because dialog boxes and notifications can take the foreground, but you do not want to dismiss those (most of the time I assume).

    Good luck!

    0 讨论(0)
提交回复
热议问题