I went to Permission Settings on my Phone & after Display pop-up window - clicked checkbox Code:
private void showAlertDialog(final Context context) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
AlertDialog.Builder builder = new AlertDialog.Builder(context, R.style.myPasscodeAlertDialog)
.setCancelable(false);
View view = inflater
.inflate(R.layout.row_passcode_dialog, null);
passcode = view.findViewById(R.id.passcode);
forgot = view.findViewById(R.id.forgot);
setTextWatcher();
setClickListener();
builder.setView(view);
dialog = builder.create();
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
if (Build.VERSION.SDK_INT >= 27) {
dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY);
} else {
dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_TOAST);
}
dialog.show();
}
I called above method from here & it is working fine for other version:
@Override
public void onActivityStarted(Activity activity) {
if (++activityReferences == 1 && !isActivityChangingConfigurations) {
showAlertDialog(getApplicationContext());
if (CREATE_PASSCODE_ACTIVITY == 0) {
dialog.show();
}
}
}
Manifest:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.ACTION_MANAGE_OVERLAY_PERMISSION" />
It means there is no use of TYPE.APPLICATION.OVERLAY What should I do? I tried everything. At least for testing purpose it should work on my Redmi Note 5 Pro 8.0.1
You should try changing your if condition like this however i'm not sure if it will work or not: