I created a cardview for the prominent disclose everything works fine but after click agree button the cardview not dismissing.
When the user click the agree button it will go to activity : startActivity(new Intent("android.settings.ACCESSIBILITY_SETTINGS"));
If the user click the disagree button it will go to activity : startActivity(new Intent(getActivity(), MainTabActivity.class));
But in the Agree button after accessibility turned on and when user back to the app still the cardview showing. So, how to disable the cardview when the user clicked agree button and at the same time the user need to reach "android.settings.ACCESSIBILITY_SETTINGS" this.
please check the code below:
private void checkAccesibleDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
LayoutInflater inflater = this.getLayoutInflater();
View dialogView = inflater.inflate(R.layout.consent_dialog, null);
CheckBox mCheckBox= dialogView.findViewById(R.id.checkBox);
Button mButton = dialogView.findViewById(R.id.button1);
Button mButton2 = dialogView.findViewById(R.id.button2);
builder.setCancelable(false);
builder.setView(dialogView);
mButton.setOnClickListener (new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity(new Intent("android.settings.ACCESSIBILITY_SETTINGS"));
startActivity(new Intent(getActivity(), TransparentActivity.class));
}
});
mButton2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity(new Intent(getActivity(), MainTabActivity.class));
}
});
AlertDialog dialog = builder.create();
dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
dialog.show();
mButton.setEnabled(false);
mCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if (mCheckBox.isChecked()) {
mButton.setEnabled(true);
} else {
mButton.setEnabled(false);
}
}
});
}
Create dialog first
builder.setView(dialogView);
AlertDialog dialog = builder.create();
Then, in onClick
mButton.setOnClickListener (new View.OnClickListener() {
@Override
public void onClick(View view) {
dialog.dismiss();
startActivity(new Intent("android.settings.ACCESSIBILITY_SETTINGS"));
}
});