[英]android popup window to run in background
how do I set android popup window to run in background. 如何设置android弹出窗口在后台运行。 I mean, I dont need to make the app open, but it will run in background, and when call, popup will appeared on android main menu.
我的意思是,我不需要打开该应用程序,但它将在后台运行,并且在调用时,弹出窗口将出现在android主菜单上。 I got the
handler
script, I just only want to know how do i set this popup to show on any screen, just like toast message
will do. 我得到了
handler
脚本,我只想知道如何设置此弹出窗口以在任何屏幕上显示,就像toast message
一样。
LayoutInflater layoutInflater = (LayoutInflater)MainActivity.this.getSystemService(LAYOUT_INFLATER_SERVICE);
final View popupView = layoutInflater.inflate(R.layout.popup, null);
final PopupWindow popupWindowDi = new PopupWindow(popupView, LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
Button btnDismiss = (Button)popupView.findViewById(R.id.dismiss);
btnDismiss.setOnClickListener(new Button.OnClickListener(){
@Override
public void onClick(View v) {
popupWindowDi.dismiss();
}});
popupWindowDi.showAsDropDown(btnOpenPopup, 50, -30);
What you need a system dialog which is shown over all activities-the facebook implements chat heads.Use this in your code: 您需要在所有活动中都显示的系统对话框-Facebook实现了聊天头,请在您的代码中使用此对话框:
popup.getWindow().setType(
WindowManager.LayoutParams.TYPE_SYSTEM_DIALOG);
popup.show();
Make sure you add SYSTEM_ALERT_WINDOW permission in your manifest.refer http://developer.android.com/reference/android/Manifest.permission.html#SYSTEM_ALERT_WINDOW 确保在清单中添加SYSTEM_ALERT_WINDOW权限。请参阅http://developer.android.com/reference/android/Manifest.permission.html#SYSTEM_ALERT_WINDOW
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.