jeet.chanchawat jeet.chanchawat - 2 years ago 89
Android Question

How to make a callback after the view is completely rendered?

How to make a callback after the view is completely rendered ?

I am trying to call a method which takes a screen-shot of parent view.
If I write that code in

method, the app crashes due to null pointer (as no view is rendered).
for now the temporary solution I have implemented is to make a delay of 1 second before calling that method.
But, I am looking for a much more robust solution to this problem.

any suggestions and help appreciated.
thanks :)

Answer Source

I have got a better option now :) this really gives a call-back after the layout is rendered

private class LoadActivity extends AsyncTask<String, Void, String> {
    protected void onPreExecute() 

    protected void onPostExecute(String result) {



    protected String doInBackground(String... params) {
        return null;

I created the above class and then called this method for execution in onCreate()

            LoadActivity loadactivity= new LoadActivity();
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download