如何在 android 系统中打开警报对话框的系统级别
1个回答
展开全部
解决方法 1:
这可能会帮助您...
@Override
public void onReceive(Context context, Intent intent) {
final WindowManager manager = (WindowManager) context.getApplicationContext().getSystemService(Context.WINDOW_SERVICE);
WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams();
layoutParams.gravity = Gravity.CENTER;
layoutParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_ALERT;
layoutParams.width = WindowManager.LayoutParams.WRAP_CONTENT;
layoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
layoutParams.alpha = 1.0f;
layoutParams.packageName = context.getPackageName();
layoutParams.buttonBrightness = 1f;
layoutParams.windowAnimations = android.R.style.Animation_Dialog;
final View view = View.inflate(context.getApplicationContext(),R.layout.test_layout, null);
Button yesButton = (Button) view.findViewById(R.id.yesButton);
Button noButton = (Button) view.findViewById(R.id.noButton);
yesButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
manager.removeView(view);
}
});
noButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
manager.removeView(view);
}
});
manager.addView(view, layoutParams);
}
}
这可能会帮助您...
@Override
public void onReceive(Context context, Intent intent) {
final WindowManager manager = (WindowManager) context.getApplicationContext().getSystemService(Context.WINDOW_SERVICE);
WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams();
layoutParams.gravity = Gravity.CENTER;
layoutParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_ALERT;
layoutParams.width = WindowManager.LayoutParams.WRAP_CONTENT;
layoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
layoutParams.alpha = 1.0f;
layoutParams.packageName = context.getPackageName();
layoutParams.buttonBrightness = 1f;
layoutParams.windowAnimations = android.R.style.Animation_Dialog;
final View view = View.inflate(context.getApplicationContext(),R.layout.test_layout, null);
Button yesButton = (Button) view.findViewById(R.id.yesButton);
Button noButton = (Button) view.findViewById(R.id.noButton);
yesButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
manager.removeView(view);
}
});
noButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
manager.removeView(view);
}
});
manager.addView(view, layoutParams);
}
}
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询