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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T00:23:49+00:00 2026-05-24T00:23:49+00:00

@Override protected void onStop() { super.onStop(); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(Test message) .setCancelable(true)

  • 0
@Override
protected void onStop() {
    super.onStop();

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setMessage("Test message")
           .setCancelable(true)
           .setPositiveButton("OK", new DialogInterface.OnClickListener() {
               public void onClick(DialogInterface dialog, int id) {
                   dialog.cancel();
               }
           });
    AlertDialog alert = builder.create();
    alert.show();
}

This obviously isn’t working, as soon as dialog is shown – activity is stopped (dialog disappears). How to solve this issuse?

I want to save some setting into my database as soon as activity is left (via back button, clicking on some button which leads to some other activity, click on notification and so on..) and then show the result in AlertDialog?

Or even better – when Android recognizes that activity will be closed, it saves my settings, show AlertDialog and then onClick Activity is finally closed.

  • 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-24T00:23:50+00:00Added an answer on May 24, 2026 at 12:23 am

    It’s a very bad practice to try to do something that takes time and user attention in onStop and onPause. Usually these methods are used to save some data. You can try to show a Toast, but the best way – is to show nothing, as it’s not an usual practice. Is there really something important you need to show? This is the question you must resolve in first place.

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

Sidebar

Related Questions

I have written a windows service in C# .NET. This windows service contains a
I'm trying to execute a .bat script in a C# windows service but it
friends, i am using following code inside asyncTask public class AsycLoaderFromDbAndMapInjector extends AsyncTask {
i am downloading data from website using asynctask and my code for async task
I have a dynamic imageview of camera picture, my problem is I want to
I'm in doubt of how works Java. I need do a code like it
how to run the async task at specific time? (I want to run it
I'm trying to call contacts through the default contacts application in a simple list
I am working on a groceries list app to learn android, but I cannot
Ok, I've read around that a custom view must have a constructor with AttributeSet

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.