title: Android, run code only after the UI has been rendered for an activity
body: <p>I know this question is on here many times, but the answer that works in all of those cases does not work for mine. When the activity starts I am taking a screenshot of the screen. I execute my code at the bottom of the onCreate. It works great 4 our of 5 times and the 5th time the screen has not rendered yet and you get a black screenshot.</p>
  
  <p>My workaround is to execute the screenshot code in an AsyncTask that is started at the end of onCreate. If I put a 200ms sleep the it works 9 out of 10 times. A 500ms sleep gets it 100% of the time but you can notice the delay. This also seems like a terrible solution because that 500ms is an arbitrary number that may not work across all devices.</p>
  
  <p>How can I know when the UI is rendered, so I can take my screenshot?</p>