I've read up on a lot of questions about immersive sticky mode on Android, but I cannot find a specific answer for my question.
I have read onBackPressed function not working under IMMERSIVE STICKY mode, but my app goes back successfully when an ImageButton is pressed.
I want to remain in immersive sticky mode for the whole duration of the app. There is no problem when I launch a new activity, with and without a shared element transition. However, when I go back, the system bars sometimes appears then soon slide out of view again. This happens especially when I stay on an activity for a while.
This transition is called from _TrickPage.class:
public void setBorroRingsOnClickListener(View view){
dBHelper.close();
Intent intent = new Intent(this, _DominoScene.class);
startActivity(intent);
}
And I call finish() to get back to _TrickPage.class from _Domino.class:
findViewById(R.id.picture).setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v){
dBHelper.close();
finish();
}
});
Another transition I use is a shared element transition. The following is an inner class of ButtonAdapter, which extends BaseAdapter, an object in my _Submenu Activity:
class MyOnClickListener implements View.OnClickListener {
private final int position;
public MyOnClickListener(int position){
this.position = position;
}
@Override
public void onClick(View v) {
...
//link clicked button to _TrickPage button for shared transition
v.setTransitionName("trick");
//make and start shared transition to _TrickPage
ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(
(Activity)mContext,
new Pair<View, String>(v, "trick")
);
Intent intent = new Intent(v.getContext(), _TrickPage.class);
v.getContext().startActivity(intent, options.toBundle());
}
}
Finally, to get back to _Submenu from _TrickPage, I call finishaftertransition():
picture.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dBHelper.close();
hideMainContent();
finishAfterTransition();
}
});
I set the UI flags in the onCreate() and onResume() methods of the Activities involved: _Submenu, _TrickPage, and _DominoScene. I also have the following in each activity:
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
//if (hasFocus)
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
if (hasFocus && playAnimations) {
//showMainContent();
playAnimations = false;
}
}
This is my first time asking a question on Stack Overflow, so please ask for any other parts of my code if you think there could be a problem there. Thanks!