android - Leaderboard activity on closing pause the game for few seconds -
i did done leaderboard inside game using codes
public void openleaderboardsactivity() { runonuithread(new runnable() { @override public void run() { if (!mhelper.issignedin()) { beginuserinitiatedsignin(); } else { string leaderboardid = getresources() .getstring(r.string.leaderboard_id); startactivityforresult(mhelper.getgamesclient() .getleaderboardintent(leaderboardid), 1001); } } }); } public void submitleaderboardsscore() { if (mhelper != null && mhelper.issignedin()) { mhelper.getgamesclient().submitscore( getresources().getstring(r.string.leaderboard_id), gamepreferences.getinstance().gethighscore()); } }
but problem when took leaderboard menu , came game paused 4 sec , resumes, same happen when take in app purchase activity too.can know if doing wrong?
is app opengl? if is, when start leaderboard, main activity's egl context being thrown away (normal, irritating android behavior). when exit leaderboard, pause happens while context re-created , of texture etc re-loaded (which typically happens in onsurfacecreated).
so, need try avoid context being lost, , therefore, re-created everytime pause activity.
if you're targeting honeycomb or above, try adding activity:
getpreserveeglcontextonpause();
otherwise can try following:
in activity's onpause(), remove view.onpause() stop context being trashed. instead, put line:
view.setvisibility(view.gone);
then override onwindowfocuschanged(boolean hasfocus) bring focus when app re-launched....
@override public void onwindowfocuschanged(boolean hasfocus) { super.onwindowfocuschanged(hasfocus); if (hasfocus && view.getvisibility() == view.gone) { view.setvisibility(view.visible); } }
this should prevent context being lost , therefore, annoying pauses! :-)
Comments
Post a Comment