Android - Launching Activity on top of other Apps

笑着哭i 提交于 2019-12-03 21:20:48

If you want to overlay an app on top of other apps, add the following code.

 WindowManager.LayoutParams windowManagerParams = new WindowManager.LayoutParams(WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY , 
            WindowManager.LayoutParams. FLAG_DIM_BEHIND, PixelFormat.TRANSLUCENT);

 WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE);

    LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
    View myView = inflater.inflate(R.layout.youractivity, null);

 wm.addView(myView, windowManagerParams);

Add permission to Android Manifest:

SYSTEM_ALERT_WINDOW

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!