Is is possible to keep alert dialog displayed after activity is destroyed?How do I display an alert dialog on Android?How to display a Yes/No dialog box on Android?Background task, progress dialog, orientation change - is there any 100% working solution?ViewPager and fragments — what's the right way to store fragment's state?Android: show Alert Dialog at any activityAndroid destroying activities, killing processesAndroid alert dialog IssueDisplay Alert Dialog when Activity onPause()How to programmatically open the Permission Screen for a specific app on Android Marshmallow?Showing Alert Dialog after Notification button tap

Lifted its hind leg on or lifted its hind leg towards?

Freedom of speech and where it applies

What was required to accept "troll"?

Giant Toughroad SLR 2 for 200 miles in two days, will it make it?

Why are all the doors on Ferenginar (the Ferengi home world) far shorter than the average Ferengi?

Is there an wasy way to program in Tikz something like the one in the image?

Should my PhD thesis be submitted under my legal name?

Hostile work environment after whistle-blowing on coworker and our boss. What do I do?

Calculating the number of days between 2 dates in Excel

I2C signal and power over long range (10meter cable)

Bob has never been a M before

Invariance of results when scaling explanatory variables in logistic regression, is there a proof?

In Star Trek IV, why did the Bounty go back to a time when whales were already rare?

Pronouncing Homer as in modern Greek

Can somebody explain Brexit in a few child-proof sentences?

Can I use my Chinese passport to enter China after I acquired another citizenship?

What does the "3am" section means in manpages?

Identify a stage play about a VR experience in which participants are encouraged to simulate performing horrific activities

The One-Electron Universe postulate is true - what simple change can I make to change the whole universe?

Can a Bard use an arcane focus?

Can a malicious addon access internet history and such in chrome/firefox?

Simple image editor tool to draw a simple box/rectangle in an existing image

Why does this part of the Space Shuttle launch pad seem to be floating in air?

Is there any significance to the Valyrian Stone vault door of Qarth?



Is is possible to keep alert dialog displayed after activity is destroyed?


How do I display an alert dialog on Android?How to display a Yes/No dialog box on Android?Background task, progress dialog, orientation change - is there any 100% working solution?ViewPager and fragments — what's the right way to store fragment's state?Android: show Alert Dialog at any activityAndroid destroying activities, killing processesAndroid alert dialog IssueDisplay Alert Dialog when Activity onPause()How to programmatically open the Permission Screen for a specific app on Android Marshmallow?Showing Alert Dialog after Notification button tap













1















I have a business logic that requires to keep an alert dialog displayed when a transition happens and an activity is destroyed and another one created.
The activity that is destroyed is the one that starts the alert dialog.

I did some research on my own and did not find any reliable solution.

If you know a solution or some workarounds that could help me that will be great.










share|improve this question






















  • why not you show your alert dialog in second activity(which is visible) ?

    – Jakir Hossain
    Mar 8 at 7:59











  • it is required to be displayed on both. because it should be displayed some time on first activity and some time after the second activity is started

    – MihaiBC
    Mar 8 at 8:01











  • take 1 activity and screens as fragments , show dialog in activity

    – Manohar Reddy
    Mar 8 at 9:05











  • Is it implemented now

    – Leo Zhu - MSFT
    Mar 22 at 9:17















1















I have a business logic that requires to keep an alert dialog displayed when a transition happens and an activity is destroyed and another one created.
The activity that is destroyed is the one that starts the alert dialog.

I did some research on my own and did not find any reliable solution.

If you know a solution or some workarounds that could help me that will be great.










share|improve this question






















  • why not you show your alert dialog in second activity(which is visible) ?

    – Jakir Hossain
    Mar 8 at 7:59











  • it is required to be displayed on both. because it should be displayed some time on first activity and some time after the second activity is started

    – MihaiBC
    Mar 8 at 8:01











  • take 1 activity and screens as fragments , show dialog in activity

    – Manohar Reddy
    Mar 8 at 9:05











  • Is it implemented now

    – Leo Zhu - MSFT
    Mar 22 at 9:17













1












1








1


1






I have a business logic that requires to keep an alert dialog displayed when a transition happens and an activity is destroyed and another one created.
The activity that is destroyed is the one that starts the alert dialog.

I did some research on my own and did not find any reliable solution.

If you know a solution or some workarounds that could help me that will be great.










share|improve this question














I have a business logic that requires to keep an alert dialog displayed when a transition happens and an activity is destroyed and another one created.
The activity that is destroyed is the one that starts the alert dialog.

I did some research on my own and did not find any reliable solution.

If you know a solution or some workarounds that could help me that will be great.







android xamarin android-activity xamarin.android alertdialog






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 8 at 7:50









MihaiBCMihaiBC

498




498












  • why not you show your alert dialog in second activity(which is visible) ?

    – Jakir Hossain
    Mar 8 at 7:59











  • it is required to be displayed on both. because it should be displayed some time on first activity and some time after the second activity is started

    – MihaiBC
    Mar 8 at 8:01











  • take 1 activity and screens as fragments , show dialog in activity

    – Manohar Reddy
    Mar 8 at 9:05











  • Is it implemented now

    – Leo Zhu - MSFT
    Mar 22 at 9:17

















  • why not you show your alert dialog in second activity(which is visible) ?

    – Jakir Hossain
    Mar 8 at 7:59











  • it is required to be displayed on both. because it should be displayed some time on first activity and some time after the second activity is started

    – MihaiBC
    Mar 8 at 8:01











  • take 1 activity and screens as fragments , show dialog in activity

    – Manohar Reddy
    Mar 8 at 9:05











  • Is it implemented now

    – Leo Zhu - MSFT
    Mar 22 at 9:17
















why not you show your alert dialog in second activity(which is visible) ?

– Jakir Hossain
Mar 8 at 7:59





why not you show your alert dialog in second activity(which is visible) ?

– Jakir Hossain
Mar 8 at 7:59













it is required to be displayed on both. because it should be displayed some time on first activity and some time after the second activity is started

– MihaiBC
Mar 8 at 8:01





it is required to be displayed on both. because it should be displayed some time on first activity and some time after the second activity is started

– MihaiBC
Mar 8 at 8:01













take 1 activity and screens as fragments , show dialog in activity

– Manohar Reddy
Mar 8 at 9:05





take 1 activity and screens as fragments , show dialog in activity

– Manohar Reddy
Mar 8 at 9:05













Is it implemented now

– Leo Zhu - MSFT
Mar 22 at 9:17





Is it implemented now

– Leo Zhu - MSFT
Mar 22 at 9:17












3 Answers
3






active

oldest

votes


















1














I usually build my dialog by giving it a reference to the current activity. And that's how at least what the guide tells us to do. So my quick answer is NO YOU CAN'T.



However an alternative is in place. Instead of creating two different activities, put them in two different fragments. Load them in one single activity where you can hook your dialog. From your activity, you can switch between your two fragments without the need to close your dialog since the activity won't destroy upon fragment switch.






share|improve this answer























  • that was the solution i thought first but the current implementation requires to much refactor in order to change it, but that will probably be the solution

    – MihaiBC
    Mar 8 at 8:25











  • we all have that one boss who does not understand our pain. :)

    – user1506104
    Mar 8 at 8:27


















1














This is my suggestion for reference only



as allowed,you could run a full transparent Activity first,then set the Dialog to system level,and instantiation Dialgo in your custom application,and you could show and dismiss the Dialog by your application



like this hierarchy : TransparentActivity(MainLauncher activity) -> Activity1 -> Activity2



you could show Dialog when Activity1 destroy and dismiss it when Activity2 create by your application.



In fact, Dialog is attached to TransparentActivity,so you should override the back button event to prevent returning to TransparentActivity.






share|improve this answer






























    0














    You can try this way



    public abstract class BaseActivity extends AppCompatActivity 

    protected void showProgressDialog(String message)
    AlertDialog.Builder alert = new AlertDialog.Builder(this);
    alert.setCancelable(false);
    alert.setTitle("your title");
    alert.setMessage(message);
    alert.create().show();






    Extends this BaseActivity in your both Activity.
    call showProgressDialog() method to show your alert message in FirstActivity and when FirstActivity is Destroyed then Call it from SecondActivity.



    Hope it will help you. Happy Coding.






    share|improve this answer
























      Your Answer






      StackExchange.ifUsing("editor", function ()
      StackExchange.using("externalEditor", function ()
      StackExchange.using("snippets", function ()
      StackExchange.snippets.init();
      );
      );
      , "code-snippets");

      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "1"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55058841%2fis-is-possible-to-keep-alert-dialog-displayed-after-activity-is-destroyed%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      1














      I usually build my dialog by giving it a reference to the current activity. And that's how at least what the guide tells us to do. So my quick answer is NO YOU CAN'T.



      However an alternative is in place. Instead of creating two different activities, put them in two different fragments. Load them in one single activity where you can hook your dialog. From your activity, you can switch between your two fragments without the need to close your dialog since the activity won't destroy upon fragment switch.






      share|improve this answer























      • that was the solution i thought first but the current implementation requires to much refactor in order to change it, but that will probably be the solution

        – MihaiBC
        Mar 8 at 8:25











      • we all have that one boss who does not understand our pain. :)

        – user1506104
        Mar 8 at 8:27















      1














      I usually build my dialog by giving it a reference to the current activity. And that's how at least what the guide tells us to do. So my quick answer is NO YOU CAN'T.



      However an alternative is in place. Instead of creating two different activities, put them in two different fragments. Load them in one single activity where you can hook your dialog. From your activity, you can switch between your two fragments without the need to close your dialog since the activity won't destroy upon fragment switch.






      share|improve this answer























      • that was the solution i thought first but the current implementation requires to much refactor in order to change it, but that will probably be the solution

        – MihaiBC
        Mar 8 at 8:25











      • we all have that one boss who does not understand our pain. :)

        – user1506104
        Mar 8 at 8:27













      1












      1








      1







      I usually build my dialog by giving it a reference to the current activity. And that's how at least what the guide tells us to do. So my quick answer is NO YOU CAN'T.



      However an alternative is in place. Instead of creating two different activities, put them in two different fragments. Load them in one single activity where you can hook your dialog. From your activity, you can switch between your two fragments without the need to close your dialog since the activity won't destroy upon fragment switch.






      share|improve this answer













      I usually build my dialog by giving it a reference to the current activity. And that's how at least what the guide tells us to do. So my quick answer is NO YOU CAN'T.



      However an alternative is in place. Instead of creating two different activities, put them in two different fragments. Load them in one single activity where you can hook your dialog. From your activity, you can switch between your two fragments without the need to close your dialog since the activity won't destroy upon fragment switch.







      share|improve this answer












      share|improve this answer



      share|improve this answer










      answered Mar 8 at 8:15









      user1506104user1506104

      1,52522144




      1,52522144












      • that was the solution i thought first but the current implementation requires to much refactor in order to change it, but that will probably be the solution

        – MihaiBC
        Mar 8 at 8:25











      • we all have that one boss who does not understand our pain. :)

        – user1506104
        Mar 8 at 8:27

















      • that was the solution i thought first but the current implementation requires to much refactor in order to change it, but that will probably be the solution

        – MihaiBC
        Mar 8 at 8:25











      • we all have that one boss who does not understand our pain. :)

        – user1506104
        Mar 8 at 8:27
















      that was the solution i thought first but the current implementation requires to much refactor in order to change it, but that will probably be the solution

      – MihaiBC
      Mar 8 at 8:25





      that was the solution i thought first but the current implementation requires to much refactor in order to change it, but that will probably be the solution

      – MihaiBC
      Mar 8 at 8:25













      we all have that one boss who does not understand our pain. :)

      – user1506104
      Mar 8 at 8:27





      we all have that one boss who does not understand our pain. :)

      – user1506104
      Mar 8 at 8:27













      1














      This is my suggestion for reference only



      as allowed,you could run a full transparent Activity first,then set the Dialog to system level,and instantiation Dialgo in your custom application,and you could show and dismiss the Dialog by your application



      like this hierarchy : TransparentActivity(MainLauncher activity) -> Activity1 -> Activity2



      you could show Dialog when Activity1 destroy and dismiss it when Activity2 create by your application.



      In fact, Dialog is attached to TransparentActivity,so you should override the back button event to prevent returning to TransparentActivity.






      share|improve this answer



























        1














        This is my suggestion for reference only



        as allowed,you could run a full transparent Activity first,then set the Dialog to system level,and instantiation Dialgo in your custom application,and you could show and dismiss the Dialog by your application



        like this hierarchy : TransparentActivity(MainLauncher activity) -> Activity1 -> Activity2



        you could show Dialog when Activity1 destroy and dismiss it when Activity2 create by your application.



        In fact, Dialog is attached to TransparentActivity,so you should override the back button event to prevent returning to TransparentActivity.






        share|improve this answer

























          1












          1








          1







          This is my suggestion for reference only



          as allowed,you could run a full transparent Activity first,then set the Dialog to system level,and instantiation Dialgo in your custom application,and you could show and dismiss the Dialog by your application



          like this hierarchy : TransparentActivity(MainLauncher activity) -> Activity1 -> Activity2



          you could show Dialog when Activity1 destroy and dismiss it when Activity2 create by your application.



          In fact, Dialog is attached to TransparentActivity,so you should override the back button event to prevent returning to TransparentActivity.






          share|improve this answer













          This is my suggestion for reference only



          as allowed,you could run a full transparent Activity first,then set the Dialog to system level,and instantiation Dialgo in your custom application,and you could show and dismiss the Dialog by your application



          like this hierarchy : TransparentActivity(MainLauncher activity) -> Activity1 -> Activity2



          you could show Dialog when Activity1 destroy and dismiss it when Activity2 create by your application.



          In fact, Dialog is attached to TransparentActivity,so you should override the back button event to prevent returning to TransparentActivity.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 13 at 4:39









          Leo Zhu - MSFTLeo Zhu - MSFT

          1,141118




          1,141118





















              0














              You can try this way



              public abstract class BaseActivity extends AppCompatActivity 

              protected void showProgressDialog(String message)
              AlertDialog.Builder alert = new AlertDialog.Builder(this);
              alert.setCancelable(false);
              alert.setTitle("your title");
              alert.setMessage(message);
              alert.create().show();






              Extends this BaseActivity in your both Activity.
              call showProgressDialog() method to show your alert message in FirstActivity and when FirstActivity is Destroyed then Call it from SecondActivity.



              Hope it will help you. Happy Coding.






              share|improve this answer





























                0














                You can try this way



                public abstract class BaseActivity extends AppCompatActivity 

                protected void showProgressDialog(String message)
                AlertDialog.Builder alert = new AlertDialog.Builder(this);
                alert.setCancelable(false);
                alert.setTitle("your title");
                alert.setMessage(message);
                alert.create().show();






                Extends this BaseActivity in your both Activity.
                call showProgressDialog() method to show your alert message in FirstActivity and when FirstActivity is Destroyed then Call it from SecondActivity.



                Hope it will help you. Happy Coding.






                share|improve this answer



























                  0












                  0








                  0







                  You can try this way



                  public abstract class BaseActivity extends AppCompatActivity 

                  protected void showProgressDialog(String message)
                  AlertDialog.Builder alert = new AlertDialog.Builder(this);
                  alert.setCancelable(false);
                  alert.setTitle("your title");
                  alert.setMessage(message);
                  alert.create().show();






                  Extends this BaseActivity in your both Activity.
                  call showProgressDialog() method to show your alert message in FirstActivity and when FirstActivity is Destroyed then Call it from SecondActivity.



                  Hope it will help you. Happy Coding.






                  share|improve this answer















                  You can try this way



                  public abstract class BaseActivity extends AppCompatActivity 

                  protected void showProgressDialog(String message)
                  AlertDialog.Builder alert = new AlertDialog.Builder(this);
                  alert.setCancelable(false);
                  alert.setTitle("your title");
                  alert.setMessage(message);
                  alert.create().show();






                  Extends this BaseActivity in your both Activity.
                  call showProgressDialog() method to show your alert message in FirstActivity and when FirstActivity is Destroyed then Call it from SecondActivity.



                  Hope it will help you. Happy Coding.







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Mar 8 at 8:34

























                  answered Mar 8 at 8:11









                  Jakir HossainJakir Hossain

                  998




                  998



























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55058841%2fis-is-possible-to-keep-alert-dialog-displayed-after-activity-is-destroyed%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      How to get text form Clipboard with JavaScript in Firefox 56?How to validate an email address in JavaScript?How do JavaScript closures work?How do I remove a property from a JavaScript object?How do you get a timestamp in JavaScript?How do I copy to the clipboard in JavaScript?How do I include a JavaScript file in another JavaScript file?Get the current URL with JavaScript?How to replace all occurrences of a string in JavaScriptHow to check whether a string contains a substring in JavaScript?How do I remove a particular element from an array in JavaScript?

                      Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme

                      List of MPs elected to the English parliament in 1640 (April) Contents List of constituencies and members See also Notes References Navigation menueNational Archives – The Glynde Place ArchivesCobbett's Parliamentary history of England, from the Norman Conquest in 1066 to the year 1803'Aldermen in Parliament', The Aldermen of the City of London: Temp. Henry III – 1912onepage&q&f&#61, false 229