How to listen window rotation finished in android? -


in app, need action when screen orientation change. following work:

//in androidmanifest.xml <!-- somesetting --> <activity android:configchanges="orientation|keyboardhidden|screensize"           android:label="@string/app_name"           android:name="mainactivity"           android:theme="@android:style/theme.notitlebar">  //in mainactivity.java     public void onconfigurationchanged(configuration newconfig) {         super.onconfigurationchanged(newconfig);         dosomething();     } 

here question:
want call dosomething() "after" orientation animation(like rotate or crossfade) finish. call right after animation start.
there listener or can listen kind of animation finish?

update 0223

fyi:

after experiments, found onconfigurationchange not reliable enough. use view.addonlayoutchangelistener attribute (view component want read value from). can make sure value after orientation. way, still need override onconfigurationchange avoid recreate whole view. may google addonlayoutchangelistener() learn how use it.

i guess, want dosomething() method should called when view drawn on layout.

so need use view.post() method achieve that. have @ following ex:

fab.post(new runnable() {         @override         public void run() {             // here              //......             //......             toast.maketext(mainactivity.this, "orientation has changed.", toast.length_short).show();         }     }); 

here fab view on want perform operation when drawn on screen (so u not need use timertask).

so told want update surfaceview when orientation changed. can use post method of surface view(like fab in above code).


Comments