本文主要是介绍Android 在service中弹对话框,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
在service中弹对话框
首先设置对话框类型:
dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
并添加android.permission.SYSTEM_ALERT_WINDOW权限
如:
AlertDialog d = new AlertDialog.Builder(this).setTitle("fadfasdf")
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
}
}).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
}
}).create();
d.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
d.show();
这篇关于Android 在service中弹对话框的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!