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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:30:39+00:00 2026-06-12T18:30:39+00:00

Possible Duplicate: Restart app to a certain activity? I am currently writing an DialogPreferences

  • 0

Possible Duplicate:
Restart app to a certain activity?

I am currently writing an DialogPreferences Activity to delete the user account. I completely deleted the user data successfully and now planning to return to the LAUNCHER screen in order to push the user make a new installation. But I really couldn’t find any way to return.

Intent is only usable from XML file as far as I understand.

Is there any way to use StartActivity() or restart the application in DialogPreferences Activity?

    public class DeleteAccountActivity extends DialogPreference {

       public DeleteAccountActivity(Context context, AttributeSet attrs) {
          super(context, attrs);
       }

       @Override
       protected void onDialogClosed(boolean positiveResult) {
          super.onDialogClosed(positiveResult);
          if (positiveResult) {
             if (DEBUG)
                Log.d(0, DEBUG_TAG, "DeleteAccountActivity");

         try {
            ...

            boolean success = rest.deregister(request);
            if (success) {
               Toast.makeText(getContext(),
                              getContext().getResources().getText(R.string.successfully_deleted_account),
                              Toast.LENGTH_LONG).show();

               SharedPreferences.Editor editor = mSharedPref.edit();
               editor.clear();
               editor.commit();

               Intent intent = new Intent();
               intent.setClass(this, A.class);
               StartActivity(intent); //error
               if (DEBUG)
                  Log.d(0, DEBUG_TAG, "Deleted the user account successfully.");
            }
         }
         catch (Exception e) {
            Log.e(0, DEBUG_TAG, "asd", e);
         }
      }
   }
}
  • 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-12T18:30:41+00:00Added an answer on June 12, 2026 at 6:30 pm

    (With your code sample I saw a solution right away, thanks for posting it!) Since startActivity() is a member of the Context class, so simply use:

    getContext().startActivity(...);
    

    And of course, rather than call getContext() three or more times you should save a reference to it in a local or class variable.

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

Sidebar

Related Questions

Possible Duplicate: Filetype association with application (C#) I'm writing a C# Windows app to
Possible Duplicate: Eclipse wont start after computer restart Lately I opened my eclipse and
Possible Duplicate: Any way to “reboot” the JVM? Is there any option to restart
Possible Duplicate: MySQL - Auto Increment after delete I want to delete the last
Possible Duplicate: Extracting dollar amounts from existing sql data? I have a column in
Possible Duplicate: how to delete a file? My application first reads the fields in
Possible Duplicate: restart application without restarting server? How do I reset a Coldfusion Application
Possible Duplicate: xCode 4 -reinstalls keychain certs that I delete The question says it
Possible Duplicate: Transparent images with C# WinForms I am coding an app which will
Possible Duplicate: “The breakpoint will not currently be hit. The source code is different

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.