thank you for your time.
I'm making this app that shows an icon over the home screen and other apps (like fb messenger) (see img1) and when you press it, the icon shows a new activity that has the options (see img3). But has this problem:
- The icon is shown behind my new overlay activity (see img3)
- fb messegner always appears over my app (see img2)
So I was thinking maybe there is a way to set the prioritys overlapping screens?
How can I show my app over other apps that also draw over other apps?
How can I get system permission to appear over the system app?
Please help.
Img2 - My app vs Fb mssgr vs System app
Img3 - I create a new overlay windows but I want my first icon appe
The permissions on my manifest:
<uses-permission android:name="android.permission.ACTION_MANAGE_OVERLAY_PERMISSION" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.CALL_PHONE" />
The Service of the Icon:
public class ServicioVentanaFlotanteIcono extends Service {
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public void onCreate() {
super.onCreate();
// Indica que mostrará el Layout ventana_flotante
final LayoutInflater inflater = (LayoutInflater) getBaseContext().getSystemService(LAYOUT_INFLATER_SERVICE);
assert inflater != null;
@SuppressLint("InflateParams") final View
customView = inflater.inflate(R.layout.ventana_flotante_icono, null);
// Inicializa el Windows Manager y muestra el Layout
wm = (WindowManager) getSystemService(WINDOW_SERVICE);
final WindowManager.LayoutParams parameters = new WindowManager.LayoutParams(
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.TYPE_PHONE,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
PixelFormat.TRANSLUCENT);
wm.addView(customView, parameters);
....
}
}
The Service with the overlay gray screen and white icon on bottom:
public class ServicioVentanaFlotanteMensajes extends Service {
@Override
public IBinder onBind(Intent intent) {
return null;
}
public void onCreate() {
super.onCreate();
// Indica que mostrará el Layout ventana_flotante_mensajes
final LayoutInflater inflater = (LayoutInflater) getBaseContext().getSystemService(LAYOUT_INFLATER_SERVICE);
customView = inflater.inflate(R.layout.ventana_flotante_mensajes, null);
// Inicializa el Windows Manager y muestra el Layout
wm = (WindowManager) getSystemService(WINDOW_SERVICE);
final WindowManager.LayoutParams parameters = new WindowManager.LayoutParams(
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.TYPE_PHONE,
WindowManager.LayoutParams.FLAG_FULLSCREEN,
PixelFormat.TRANSLUCENT);
wm.addView(customView, parameters);
...
}
}
I have find a way to show the icon over the others apps, it was adding differents Layout params for each one:
To the screen you want shows on top:
LayoutParams.type = WindowManager.LayoutParams.TYPE_PRIORITY_PHONE;