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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T11:57:19+00:00 2026-06-05T11:57:19+00:00

I have a class ActivityExitDialogFragment that extends android.support.v4.app.DialogFragment. There are only 2 methods in

  • 0

I have a class ActivityExitDialogFragment that extends android.support.v4.app.DialogFragment. There are only 2 methods in ActivityExitDialogFragment, onCreateDialog and newInstance to get a new instance of ActivityExitDialogFragment. Here they are:

public Dialog onCreateDialog(Bundle savedInstanceState) {
    String title = getArguments().getString("title");
Dialog myDialog = new AlertDialog.Builder(getActivity())
.setIcon(R.drawable.ic_launcher)
.setTitle(title)
.setNegativeButton("No", new DialogInterface.OnClickListener() {

    @Override
    public void onClick(DialogInterface dialog, int which) {
        // Dismiss the dialog.
        dismiss();
    }
    })
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {

    @Override
    public void onClick(DialogInterface dialog, int which) {
        // Close the Activity.
        getActivity().finish();
    }
}).create();

return myDialog;
}

static ActivityExitDialogFragment newInstance(String message) {
ActivityExitDialogFragment dialog = new ActivityExitDialogFragment();
Bundle args = new Bundle();
args.putString("title", message);
dialog.setArguments(args);
return dialog;
}

And here is the method used to show the dialog. Its in a different activity in the same package. It’s called when the user clicks the exit button:

public void cancelButton(View v) {
    ActivityExitDialogFragment dialog =                        
    ActivityExitDialogFragment.newInstance(exitMessage);

    dialog.show(new FragmentActivity().getSupportFragmentManager(),               
    "Exiting");
}

Whenever I click the exit button I get an IllegalStateException at the dialog.show line. I had this problem before and it was because I didn’t have the android-support-v4.jar file in the libs folder of my project. I put that jar file in the libs folder and it worked. I changed the name of the class from something else to ActivityExitDialogFragment and had eclipse change the name of the java file to match. And since then I’m getting this exception again. I dont know if its a coincidnece that I got the exception again after changing the name or if eclipse does something other that just change the name of the jar file to match the name of the public class. I have tried changing access modifiers for the getInstance method, deleting and adding a new copy of the android support jar file, changing the name back to the old name, and have been spending a few hours on Google but I have not found an answer yet.

  • 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-05T11:57:21+00:00Added an answer on June 5, 2026 at 11:57 am

    You shouldn’t try to directly instantiate an Activity with new. Instead get the fragment manager directly from the activity you have:

    dialog.show(getSupportFragmentManager(),               
    "Exiting");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have class that extends BroadcastReceiver and gets all new sms. When I get
I have Class which Extends View I'm able To Move one Image Over another
I have class class User extends BaseModel{ public $id; public $name; } class BaseModel{
I have class ParentClass that observes an NSNotification. ParentClass handles the notification. ChildClass inherits
I have class class DateOptTimeType implements org.hibernate.usertype.UserType that works with two columns @org.hibernate.annotations.Type(type =
I have class X and in it there is a static method called doStuff()
I have class B that has class A, this is simplified version of class
I have class instantiated in a web service that, in a static member, holds
I have :- Class Abc extends Activity(){ private ActivityManager am; private List<RunningAppProcessInfo> rList; @Override
I have class User that contains protected constructor and class Account that has access

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.