I am inflating view using window manager for lock.But I want to display dialog on it when it display wrong lock many times.Dialog is display under layout inflated by window manager in background.I can't find much about it.
My code for display dialog is:
pDialog = new SweetAlertDialog(context, SweetAlertDialog.WARNING_TYPE)
.setTitleText("Internet Error !")
.setContentText("Do you want to enable internet?")
.setCancelText("No,Cancel plz!")
.setConfirmText("Yes,Enable it")
.showCancelButton(true)
.setCancelClickListener(
new SweetAlertDialog.OnSweetClickListener() {
@Override
public void onClick(SweetAlertDialog sDialog) {
sDialog.setTitleText("Cancelled!")
.setContentText(
"You Can't Enable Internet")
.setConfirmText("OK")
.showCancelButton(false)
.setCancelClickListener(null)
.setConfirmClickListener(null)
.changeAlertType(
SweetAlertDialog.ERROR_TYPE);
}
})
.setConfirmClickListener(
new SweetAlertDialog.OnSweetClickListener() {
@Override
public void onClick(
SweetAlertDialog sweetAlertDialog) {
Intent intent = new Intent();
intent.setAction(Settings.ACTION_DATA_ROAMING_SETTINGS);
context.startActivity(intent);
sweetAlertDialog.dismiss();
}
});
pDialog.getWindow().setType(
WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
pDialog.show();
for layout inflate in window manager:
this.context = context;
if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) {
Log.d("tagKrishna", "come in if");
} else {
Log.d("tagKrishna", "come in else");
numLockView = View.inflate(context, R.layout.activity_receiver,
null);
numLockView2 = View.inflate(context,
R.layout.activity_unclock_photo_lock_screen, null);
numLockView3 = View.inflate(context,
R.layout.unlock_pin_lock_screen, null);
numLockView4 = View
.inflate(context, R.layout.forget_passcode, null);
bindView();
// params = new WindowManager.LayoutParams(
// WindowManager.LayoutParams.MATCH_PARENT,
// WindowManager.LayoutParams.MATCH_PARENT,
// 2003 ,
// 262184, PixelFormat.TRANSLUCENT);
params = new WindowManager.LayoutParams(
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.TYPE_SYSTEM_ERROR,
WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
| WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH
| WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
| WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN,
PixelFormat.TRANSLUCENT);
windowManager = (WindowManager) context.getSystemService("window");
windowManager.addView(numLockView, params);
init();
addListener();
}