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 7714589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:10:03+00:00 2026-06-01T02:10:03+00:00

Relevant Code Snippet: public class MyPreference extends Preference { public MyPreference(Context context, AttributeSet attrs)

  • 0

Relevant Code Snippet:

public class MyPreference extends Preference {

    public MyPreference(Context context, AttributeSet attrs) {
    super(context, attrs);
    this.ctx = context;

        this.setOnPreferenceClickListener(new OnPreferenceClickListener() {

            public boolean onPreferenceClick(Preference preference) {
                Toast.makeText(ctx, "Preference has been clicked", Toast.LENGTH_LONG).show();

                return true;
            }
        });
    }
}

Now I want to do some processing(basically call finish()) once the onPreferenceClick handler returns me true.

Pointers?

EDIT
Added finish() inside the onClick but its not working. No error. Just a Toast and nothing else. My intention is to close the app once MyPreferenceis clicked

public boolean onPreferenceClick(Preference preference) {
                Toast.makeText(ctx, "Preference has been clicked", Toast.LENGTH_LONG).show();

                MainPreferenceActivity mainPref = new MainPreferenceActivity();
                mainPref.finish();

                return true;
            }

Probably I am doing it incorrectly. Creating a newInstance of MainActivity will not kill the parent MainActivity I guess, right? I am new to Java n android. Sorry 🙁 !

  • 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-01T02:10:04+00:00Added an answer on June 1, 2026 at 2:10 am

    Try Debugging the Code with Eclipse where you can set the Debugging Points and can check the flow and also different values in every variable. Even you can check step by step debugging.

    Moving to next Debug point with f8 and Debugging with step by step is with f6.

    This can be helpful top check every where in the code.

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

Sidebar

Related Questions

Here's the relevant code snippet. public static Territory[] assignTerri (Territory[] board, String[] colors) {
Relevant snippet from test.html: <div id="seat_31F_vacant" class="seatVacant" onclick="UpdateHost(this);Common.DoPostBack('lbtPostBack','31F');" onmouseover="Seat_onMouseOver(this)" onmouseout="Seat_onMouseOut(this)">F</div> Now consider this ruby
here is the relevent code snippet: public static Rand searchCount (int[] x) { int
Here's the relevant code: public static void printBoarders (Territory x) { int t =
Here's the relevant bit of the source code: class Dice { String name ;
The relevant snippet of HTML: <span class=a> <div class=fieldname>Question 1</div> <input type=text value= name=q1
Let's look at the following code snippet in Java. package trickyjava; class A {
So I have something like the following: public class Enclosing<T extends Comparable<T>> { //
Reviewing a quite old project I found the following curious code snippet (only relevant
Here's my code: // Not all headers are relevant to the code snippet. #include

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.