I'm trying to implement an activity with full screen, called immersive mode too. On android documentation I read: "When immersive full-screen mode is enabled, your activity continues to receive all touch events. The user can reveal the system bars with an inward swipe along the region where the system bars normally appear." I tried a lot of examples on android studio with emulator, and also with my own code I can enter the immersive full screen mode, but I can't exit from that. It would be simple, only an inward swipe gesture to redisplay the actionbar, but I can't. I noticed that also the riminder bubble doesn't show when enter the immersive mode for the first time, also after I shut off and reopened the virtual device. Here is the code, the gradle (the avd used is lollipop api level 21):
package net.missionaridellavia.gospelway.activity;
import android.os.Bundle;
import android.view.View;
import net.missionaridellavia.gospelway.R;
public class MainActivity extends AbstractCustomActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.container);
}
@Override
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);}
}
}
package net.missionaridellavia.gospelway.activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.view.Menu;
import android.view.MenuItem;
import net.missionaridellavia.gospelway.R;
import net.missionaridellavia.gospelway.service.DebuggerActivity;
public class AbstractCustomActivity extends DebuggerActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//
final ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
finish();
return true;
case R.id.action_settings:
Intent intentSettings = new Intent(getApplicationContext(),
SettingsActivity.class);
startActivity(intentSettings);
return true;
}
return super.onOptionsItemSelected(item);
}
}
The buil.gradle is:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "net.missionaridellavia.gospelway"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.android.support:support-v4:22.2.1'
}