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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:40:04+00:00 2026-05-25T23:40:04+00:00

Is there any possibility to intercept the key button in DialogFragment ? sorry for

  • 0

Is there any possibility to intercept the key button in DialogFragment? sorry for the naive question.. the onBackPressed of my FragmentActivity is never called.

thanks in advance

    if (imageFile.exists()) {
            ShowPicDialog newFragment = ShowPicDialog.newInstance();
            FragmentTransaction ft = manager.beginTransaction();
            Fragment prev = manager.findFragmentByTag("picDialog");
            if (prev != null) {
                ft.remove(prev);
            }

            ft.addToBackStack("picDialog");
            newFragment.getArguments().putString("path", imageFile.getAbsolutePath());
            newFragment.show(ft, "picDialog");
        }

sorry I added the snip of code I use to show the dialog.

  • 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-25T23:40:05+00:00Added an answer on May 25, 2026 at 11:40 pm

    It’s hard to say for sure what the issue is, since you haven’t posted any code. But my first guess is that you haven’t added the DialogFragment to the back stack by calling the addToBackStack method of the FragmentTransaction that you’re using to add your fragment to the activity.

    There are examples right in the Android documentation pages that give examples of a good pattern for using a DialogFragment in your Activity.

    Since you are displaying a Dialog, the created Dialog will receive the key events, not the parent Activity. So, set a Dialog.OnKeyListener when you create the Dialog’s fragment, and call setCancelable(false) on the Dialog to prevent the back key from dismissing it. You can then handle the back key in your OnKeyListener‘s onkey method.

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

Sidebar

Related Questions

Is there any possibility of exceptions to occur other than RuntimeException in Java? Thanks.
Is there any possibility to make a link or a button to close the
Is there any possibility of having a button which will execute and action in
Is there any possibility to operate with locksreen image in windowsPhone? For example, writing
Is there any possibility that GetPropInfo returns nil even if the given class is
Is there any possibility how to enumerate AppDomains within Process?
Is there any possibility to run Hyper-V Manager MMC SnapIn on Windows 2008 Web
Is there any possibility to select a option field by default in a g:select
Is there any possibility to extract globalize2 translation for specified locale without setting I18n.locale
Is there any possibility of changing the MySQL DB table's field name or adding

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.