How to keep a foreground app running 24/7?

前端 未结 7 730
时光说笑
时光说笑 2021-01-30 18:25

I am looking into how to keep my Android app running in the foreground.

It will be a privately distributed app, so I can do anything possible to make sure it runs consta

7条回答
  •  渐次进展
    2021-01-30 19:06

    You could make your app become a launcher, by adding 2 following category tags into tags:

      
      
    

    then you should always check if there's another app run on top, run following code to direct user to our app:

      Intent startMain = new Intent(Intent.ACTION_MAIN);
      startMain.addCategory(Intent.CATEGORY_HOME);
      startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
      startActivity(startMain);
    

    I have tried this solution, but it cannot hide apps that draw on top, like Facebook Messenger chat head.

提交回复
热议问题