开发者

add a view using the broadcast receiver to the top activity which is running currently?

开发者 https://www.devze.com 2023-04-04 00:38 出处:网络
Can i add a view to the top activity in broadcast receiver. ActivityManager am = (ActivityManager) mContext

Can i add a view to the top activity in broadcast receiver.

ActivityManager am = (ActivityManager) mContext
                            .getSystemService(Context.ACTIVITY_SERVICE);
        List<RunningTaskInfo> taskInfo = am.getRunningTasks(1);
        ComponentName componentInfo = taskInfo.get(0).topActivity;

componentInfo.getClassName() re开发者_运维知识库turns the class name of the top activity running. I can also get the package name. Can I add a view or some animation on current top activity. I need the layout name in most cases to bind to it but I am not able to figure out how to do it.


You can't do that, it would be quite a security concern if you do. However you may be able to start a new activity that's on top of it and doesn't cover the entire screen? What are you ultimately trying to accomplish?


Ok . i figured out . I started a service in the background , and then i got hold of the WindowManager and then inflated the view to be added . Then i used windowmanager.addView(inflatedView) .

0

精彩评论

暂无评论...
验证码 换一张
取 消