Android: How to draw free on top of anything (any activity)

后端 未结 2 892
不知归路
不知归路 2021-01-30 23:16

How do you draw a view on top of all other activities regardless of what they are showing and without using transparent activities or consuming its touch events.

Its lik

2条回答
  •  深忆病人
    2021-01-30 23:35

    Take a look at this cool article, I think that's exactly what you want :

    http://www.piwai.info/chatheads-basics

    In short : you want to add this permission to your manifest :

    
    

    For api >= 23, you'll need to request the runtime permission Settings.ACTION_MANAGE_OVERLAY_PERMISSION

    Then in a service, get the window manager

    windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
    

    and add your views with the addView method

提交回复
热议问题