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

  • Home
  • SEARCH
  • 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 591815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:40:27+00:00 2026-05-13T15:40:27+00:00

My application has a setting menu which is actually a PreferenceActivity. When it’s created,

  • 0

My application has a setting menu which is actually a PreferenceActivity.
When it’s created, if a boolean value is not set I want to go to the DialogPreference which sets that.

I tried doing it with an intent but the application force closed with this error msg:

E/AndroidRuntime( 239):
android.content.ActivityNotFoundException:
Unable to find explicit activity class
{com.xxxx/com.xxxx.xxxxPreference};
have you declared this activity in
your AndroidManifest.xml?

How should I do this? It’s ok to add that DialogPreference to the manifest?

  • 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-05-13T15:40:28+00:00Added an answer on May 13, 2026 at 3:40 pm

    A DialogPreference isn’t an Activity in its own right. It’s just a Preference which displays a Dialog when clicked.

    The problem is that there’s no obvious way programmatically click a Preference. However, since you’re using DialogPreference you’ve already got you own subclass of it. So we can solve our problem by adding the following method to your subclass of DialogPreference:

    //Expose the protected onClick method
    void show() {
        onClick();
    }
    

    Then in the onCreate() of your PreferencesActivity you’ll have something like this to load the preferences from your XML file:

    // Load the preferences from an XML resource
    addPreferencesFromResource(R.xml.preferences);
    

    After that you can put some code like this:

    booleanProp = true; //set this to the value of the property you're checking     
    
    if (! booleanProp) {
        //Find the Preference via its android:key
        //MyDialogPreference is your subclasss of DialogPreference
        MyDialogPreference dp = (MyDialogPreference)getPreferenceScreen().findPreference("dialog_preference");  
        dp.show();
    }
    

    This is a bit of hack, as exposing protected methods isn’t ideal, but it does work.

    Another option would be to replace the Dialog with a PrefenceActivity which contained all the options you wish to maintain and then you could launch it via an Intent, but I’m assuming there’s a good reason that you want your own custom Dialog with a specific layout. If you do want a second PreferenceActivity you can add it to your preferences XML file as follows:

    <PreferenceScreen
            android:title="@string/title_of_preference"
            android:summary="@string/summary_of_preference">
        <intent android:action="your.action.goes.HERE"/>
    </PreferenceScreen>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 317k
  • Answers 317k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer My opinion: Do it on server side. We are putting… May 13, 2026 at 11:42 pm
  • Editorial Team
    Editorial Team added an answer To do what you're trying to do, there is probably… May 13, 2026 at 11:42 pm
  • Editorial Team
    Editorial Team added an answer As others have mentioned, the right mouse button can be… May 13, 2026 at 11:42 pm

Related Questions

I have an application that sits in the status bar on the Mac. It
Background: I built an installer for my app, and all my dll's and content
I have a windows form application that uses a Shared class to house all
I am writing an application in JavaScript (with JQuery). The application has a lot
I'm having a really annoying problem with debugging javascript with VS2008. If I simply

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.