如何绘制覆盖其他应用程序的应用程序? - 设定优先次序?
How to draw over apps that draw over other apps? - Setting Priorities?
感谢您的宝贵时间。
我正在制作这个应用程序,它在主屏幕和其他应用程序(如 fb messenger)上显示一个图标(参见 img1),当您按下它时,该图标会显示一个新的 activity,其中包含选项(参见 img3)。但是有这个问题:
- 图标显示在我的新叠加层后面 activity(参见 img3)
- fb messegner 总是出现在我的应用程序上(参见 img2)
所以我在想也许有一种方法可以设置重叠屏幕的优先级?
如何让我的应用显示在其他应用之上,而这些应用也覆盖了其他应用?
如何才能获得系统权限出现在系统app上?
请帮忙
Img1 - My app
Img2 - My app vs Fb mssgr vs System app
Img3 - I create a new overlay windows but I want my first icon appe
我的清单上的权限:
<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" />
偶像的服务:
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);
....
}
}
带有灰色屏幕和底部白色图标的服务:
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);
...
}
}
它指出:
Window type: Application overlay windows are displayed above all activity windows (types between FIRST_APPLICATION_WINDOW and LAST_APPLICATION_WINDOW) but below critical system windows like the status bar or IME.
但是在它之后直接说:
The system may change the position, size, or visibility of these windows at anytime to reduce visual clutter to the user and also manage resources.....
The system will adjust the importance of processes with this window type to reduce the chance of the low-memory-killer killing them.
结果是您无权知道谁被放在前面或后面,系统会为您确定,并且主要基于 memory/cpu 使用情况和屏幕 space。
我找到了一种在其他应用程序上显示图标的方法,它为每个应用程序添加了不同的布局参数:
您想要显示在最上面的屏幕:
LayoutParams.type = WindowManager.LayoutParams.TYPE_PRIORITY_PHONE;
感谢您的宝贵时间。
我正在制作这个应用程序,它在主屏幕和其他应用程序(如 fb messenger)上显示一个图标(参见 img1),当您按下它时,该图标会显示一个新的 activity,其中包含选项(参见 img3)。但是有这个问题:
- 图标显示在我的新叠加层后面 activity(参见 img3)
- fb messegner 总是出现在我的应用程序上(参见 img2)
所以我在想也许有一种方法可以设置重叠屏幕的优先级?
如何让我的应用显示在其他应用之上,而这些应用也覆盖了其他应用?
如何才能获得系统权限出现在系统app上?
请帮忙
Img1 - My app
Img2 - My app vs Fb mssgr vs System app
Img3 - I create a new overlay windows but I want my first icon appe
我的清单上的权限:
<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" />
偶像的服务:
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);
....
}
}
带有灰色屏幕和底部白色图标的服务:
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);
...
}
}
它指出:
Window type: Application overlay windows are displayed above all activity windows (types between FIRST_APPLICATION_WINDOW and LAST_APPLICATION_WINDOW) but below critical system windows like the status bar or IME.
但是在它之后直接说:
The system may change the position, size, or visibility of these windows at anytime to reduce visual clutter to the user and also manage resources.....
The system will adjust the importance of processes with this window type to reduce the chance of the low-memory-killer killing them.
结果是您无权知道谁被放在前面或后面,系统会为您确定,并且主要基于 memory/cpu 使用情况和屏幕 space。
我找到了一种在其他应用程序上显示图标的方法,它为每个应用程序添加了不同的布局参数:
您想要显示在最上面的屏幕:
LayoutParams.type = WindowManager.LayoutParams.TYPE_PRIORITY_PHONE;