I'm new to this forum, and first of all, i apologize for my English,
I have a question about Android 6.0.1,
I'm customizing the operating system with the source codes for the IMX6 board.
It's possible to remove or hide the "status bar" (notification bar) on the top of the operating system by editing the build.prop file or others files?
Thank you in advance,
public class WelcomeActivity extends AppCompatActivity{
#Override
protected void onCreate(#Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_welcome);
}
}
write this code in activity's onCreate method
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
setContentView(R.layout.activity_splash);
}
Related
When the Android device set to dark mode.
But the user wants to see Light mode only on this app.
Is there any idea to handle this?
This code does not work for me
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)
none of these codes is working
val config: Configuration = resources.getConfiguration()
config.uiMode = Configuration.UI_MODE_NIGHT_NO
resources.configuration.uiMode= Configuration.UI_MODE_NIGHT_NO
applicationContext.createConfigurationContext(config)
resources.updateConfiguration(config, getResources().getDisplayMetrics())
I would like to see the method too, where you set once for all your activities. But as far I know you have to set in each activity before showing any views.
For reference check this:
http://www.anddev.org/applying_a_theme_to_your_application-t817.html
Edit (copied from that forum):
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Call setTheme before creation of any(!) View.
setTheme(android.R.style.Theme_Dark);
// ...
setContentView(R.layout.main);
}
Edit
If you call setTheme after super.onCreate(savedInstanceState); your activity recreated but if you call setTheme before super.onCreate(savedInstanceState); your theme will set and activity does not recreate anymore
protected void onCreate(Bundle savedInstanceState) {
setTheme(android.R.style.Theme_Dark);
super.onCreate(savedInstanceState);
// ...
setContentView(R.layout.main);
}
I have to inherit a custom main activity class which is a 3rd party lib and I cannot make any change to the class. This class adds FLAG_LAYOUT_IN_SCREEN to the window and it causes the app to be on full screen. However, I wanna prevent this behavior. So, the question is how can I clear/disable the full screen mode and can display navigation bar/status bar?
Here is the custom main activity class
public class CustomActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
setContentView(new FrameLayout(this));
// rest...
}
}
Here is my activity class:
public class MyActivity extends CustomActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// tried these attempts below, but none of them prevented
// the fullscreen mode which hides navigation bar and status bar.
this.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
this.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
this.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
}
Note: You can also test it on a sample app easily. You would notice once you add the FLAG_LAYOUT_IN_SCREEN, full-screen mode remains for different attempts as well.
public class MainActivity extends Activity {
private FrameLayout mainLayout;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.getWindow().addFlags(FLAG_LAYOUT_IN_SCREEN);
setContentView(new FrameLayout(this));
this.getWindow().clearFlags(FLAG_LAYOUT_IN_SCREEN);
this.getWindow().addFlags(FLAG_KEEP_SCREEN_ON);
}
Please apply the following to the app to not be as full screen (showing status bar)
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
I'm having trouble putting my application fullscreen in Android Lollipop, my code :
public class AoA extends ActionBarActivity {
protected void oncreate(Bundle savedInstanceState) {
super.onCreate(SavedInstanceState);
setupParameters();
}
public void setupParameters() {
GameParameterSingleton.ORIENTATION = GameParameterSingleton.PORTRAIT;
GameParameterSingleton.SCREEN_HEIGHT= getWindowManager().getDefaultDisplay().getHeight();
GameParameterSingleton.SCREEN_WIDTH = getWindowManager().getDefaultDisplay().getWidth();
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
requestWindowFeature(Window.FEATURE_NO_TITLE);
}
}
The application works when I do not use fullscreen,
Can anyone help me as I leave fulllscreen ? as I take the title of the application?
It seems that in API 21
this.supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
Doesn't work .
Try to Add this to your AndroidManifest.xml file
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
Or add this
this.getActionBar().hide();
in onCreate method after super.onCreate(savedInstanceState);
I am curious to know if screenshots can be disabled when running a android app if I were to design one.
You are welcome to use FLAG_SECURE to block screenshots and thumbnails of your activities:
public class FlagSecureTestActivity extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(LayoutParams.FLAG_SECURE,
LayoutParams.FLAG_SECURE);
setContentView(R.layout.main);
}
}
I'm developing some sample code.
I had some problem using cocos2d.
That is the CCGLSurfaceView problem.
Firstly, I imported cocos2d.jar in my project with fps_images.png file.
And i modify my project for using the cocos2d library.
Here are the code.
public class ToadActivity extends Activity {
protected CCGLSurfaceView _glSurfaceView;
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON, WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
_glSurfaceView = new CCGLSurfaceView(this);
setContentView(_glSurfaceView);
}
#Override
public void onStart()
{
super.onStart();
CCDirector.sharedDirector().attachInView(_glSurfaceView);
CCDirector.sharedDirector().setDisplayFPS(true);
CCDirector.sharedDirector().setAnimationInterval(1.0f / 60.0f);
}
}
==>>> _glSurfaceView = new CCGLSurfaceView(this);
Here, My application found a error. And at the result, it is killed in my android simulator.
What's the problem?
That library are decreated, not update more. It will be better start using: http://www.cocos2d-x.org/. It use c++, to work on android, use JNI (Native code). Code can be ported to other plataforms, like IOs.
Hope it help!