android - Get state of activity (paused / resumed) -


i using loadermanager data , when finishes child fragment should shown. in cases happens when activity in paused state , can not perform fragment transaction.

is there way current state of activity (seems have mresume flag)? or have maintain own boolean?

a quick in activity source code indicates activity class keep track on resume state member mresumed. since mresume not public , isresumed() hidden, can't use them.

you can have simple solution provide information classes. create base activity class store state. example:

public class activitybase extends activity {      private boolean misresumed = false;      @override     public void onresume() {         super.onresume()         misresumed = true;     }      @override     public void onpaused() {         super.onpaused()         misresumed = false;     }      public boolean isresumed() {         return misresumed     }  } 

simply extend class class:

public class myactivity extends activitybase {      private void onloaddone() {         if (isresumed()) {             // show fragment         }     }  } 

Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -