运行上面的其他应用程序,申请 [英] Having application running above other app

查看:153
本文介绍了运行上面的其他应用程序,申请的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想制作能上的任何应用程序中打开一个活动。

I want to make an activity that can be opened above ANY app.

通常情况下,即使当活动被设置为对话框,当您切换到我的应用程序,你看我的应用程序,并在后台可以看到发射器:

Normally, even when the activity is set as dialog, when you switch to my app, you see my app, and in the background you see the launcher:

但是,我希望应用程序会高于任何这样的程序:(在Photoshop制作):

BUT, I want the app will go above any app like this: (made in photoshop):

我没有看到这个问题,<一个href="http://stackoverflow.com/questions/4481226/creating-a-system-overlay-always-on-top-button-in-android">Creating系统覆盖窗口(总在最前面),但在ICS没有functionallity的布局。 此外,我想给从我的应用程序对话框没有减少其他的应用...

I did see this question Creating a system overlay window (always on top), but in ICS there is no functionallity to the layout. Furthermore, I want to give a dialog box from my app without minimizing the other app...

推荐答案

有很多,显示的一切都像上面的浮动视图的应用程序:airbrowser,的LilyPad,坚持下去,AirTerm,智能任务栏,aircalc ...

there are plenty of apps that show a floating view on top of everything like : airbrowser , LilyPad , Stick it , AirTerm , Smart Taskbar , aircalc ...

反正,为了实现这个功能,你必须有一个名为android.permission.SYSTEM_ALERT_WINDOW的特别许可,并使用类似的东西:

anyway , in order to achieve this feature , you must have a special permission called "android.permission.SYSTEM_ALERT_WINDOW" , and use something like that:

final WindowManager.LayoutParams param=new WindowManager.LayoutParams();
param.flags=WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
final View view=findViewById(R.id.my_floating_view);
final ViewGroup parent=(ViewGroup)view.getParent();
if(parent!=null)
  parent.removeView(view);
param.format=PixelFormat.RGBA_8888;
param.type=WindowManager.LayoutParams.TYPE_SYSTEM_ALERT;
param.gravity=Gravity.TOP|Gravity.LEFT;
param.width=parent!=null?LayoutParams.WRAP_CONTENT:view.getLayoutParams().width;
param.height=parent!=null?LayoutParams.WRAP_CONTENT:view.getLayoutParams().height;
final WindowManager wmgr=(WindowManager)getApplicationContext().getSystemService(Context.WINDOW_SERVICE);
wmgr.addView(view,param);
// TODO handle overlapping title bar and/or action bar
// TODO you must add logic to remove the view
// TODO you must use a special permission to use this method :android.permission.SYSTEM_ALERT_WINDOW
// TODO if you wish to let the view stay when leaving the app, make sure you have a foreground service running.

这篇关于运行上面的其他应用程序,申请的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆