Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8526143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:11:19+00:00 2026-06-11T08:11:19+00:00

I repair big android app and I have many custom dialogs which inherit from

  • 0

I repair big android app and I have many custom dialogs which inherit from various types of standard android dialogs (AlertDialog, ProgressDialog, …).

I have to add option “setCanceledOnTouchOutside(false)” for all dialogs in app, because in ICS we have this option set on true by default android 4.0 Dialog gets canceled when touched outside of dialog window

I can add line “*dialog.setCanceledOnTouchOutside(false)” for every dialog in my project, but this is hard to maintanence solution.

I can’t inherit from MyDialog which inherit from Dialog, because I inherit from AlertDialog, ProgressDialog,… too.

Probably the best solution would be set all dialogs option for whole project in one place or make any hack that give us by default behavior from older android version than ICS, but I don’t know if it is possible and how to do this?

Can You advise me?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T08:11:20+00:00Added an answer on June 11, 2026 at 8:11 am

    have all the dialogs implement a common interface, like this,

    interface DialogSettings {
       void setCancelOnTouchOutside(boolean cancel);
    }
    

    now implement a stand-alone version of this,

    class VersionAwareDialogSettings implements DialogSettings {
       private final Dialog d;
    
       DialogSettingsImpl(Dialog d) {
          this.d = d;
       }
    
       @Override
       void setCancelOnTouchOutside(boolean cancel) {
          if (Build.Version.SDK_INT ...) {
            d.setCancelOnTouchOutside(cancel);
          }
       }
    }
    

    now, in all your dialog classes, implement this interface, like this,

    class MyDialog extends AlertDialog implement DialogSettings {
    ...
      @Override
      public void setCancelOnTouchOutside(boolean cancel) {
        new VersionAwareDialogSettings(this).setCancelOnTouchOutside(cancel);
      }
    }
    

    this can seem like a lof of cruft, but it’s a nice separation of concerns. if you want to add a version-aware dialog setting, change the interface, and all parts of your code that you need to modify are flagged. if you need to change the impl of a verison-aware dialog setting, just change it in one place: VersionAwareDialogSettings.

    you should be more concerned with writing correct code than trying to cut down on the number of lines you write. i don’t know about you, but i can type much faster than i think. my brain is the bottleneck.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to repair parts of an XML-Document which is coming in from the
1.We have opened app. 2.Then we hide it. 3.Then we repair it . 4.And
How can I call Access's Compact and Repair Database utility from within C++? I'm
I have a large mysql MyISAM table with 1.5mil rows and 4.5GB big, still
I have an Access database that is corrupted beyond all repair (don't ask me
I currently have a broken site structure that needs repair and I want to
I have a function which saves a message in a database. There are different
I have some problems understanding how the 'repair button' works in burn. If my
On this page in the left column(header titled, Service, Repair, About) I have a
I have 2 tables 1_products id, code, make, model, fk_group_id 1_stock id, stock, repair

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.