// Setup activity layout
@Override protected void onCreate(Bundle savedInstanceState)
{
requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
String cmdLine = updateUnityCommandLineArguments(getIntent().getStringExtra("unity"));
getIntent().putExtra("unity", cmdLine);
mUnityPlayer = new UnityPlayer(this, this);
setContentView(mUnityPlayer);
mUnityPlayer.requestFocus();
getWindow().clearFlags(1024);
showSystemUi();
addUiVisibilityChangeListener();
}
private static int getLowProfileFlag() {
return (Build.VERSION.SDK_INT >= 19) ? 5894 : 1;
}
private void showSystemUi() {
if (Build.VERSION.SDK_INT < 11)
return;
this.mUnityPlayer.setSystemUiVisibility(this.mUnityPlayer.getSystemUiVisibility() & (getLowProfileFlag() ^ 0xFFFFFFFF));
}
private void addUiVisibilityChangeListener() {
if (Build.VERSION.SDK_INT < 11)
return;
this.mUnityPlayer.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
public void onSystemUiVisibilityChange(int visibility) {
UnityPlayerActivity.this.showSystemUi();
}
});
}