Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>there are 2 things you have to handle:</p> <ol> <li><p>showing a view on top. for this, you need to use a special permission <a href="http://developer.android.com/reference/android/view/WindowManager.LayoutParams.html#TYPE_SYSTEM_ALERT" rel="nofollow">TYPE_SYSTEM_ALERT</a> . here's a code for showing a view on top:</p> <blockquote> <pre><code>final WindowManager.LayoutParams param=new WindowManager.LayoutParams(); param.flags=WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; final View view=findViewById(R.id.view1); 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=view.getLayoutParams().width; param.height=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 </code></pre> </blockquote></li> <li><p>keeping the app alive. for this, you need to create a service that runs in the foreground, which means it uses a notification. <a href="http://developer.android.com/guide/components/services.html#Foreground" rel="nofollow">here's a link</a>.</p></li> </ol> <p>there are plenty of apps that have this ability. the first one i've seen was <a href="https://play.google.com/store/apps/details?id=com.myboyfriendisageek.aircalc&amp;hl=en" rel="nofollow">AirCalc</a>.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload