i create a lockscreen application.. this application is triggered by SMS.. when a SMS containing command was received, it will display a lock screen activity.
my lockscreen activity is using TYPE_KEYGUARD for disabling a home screen button. When device screen turn off and then i turn it on again, my problem is status bar / notification bar still appear on my screen. this is a problem because the user still can access some program through status bar / notification bar even the device is being locked. so i want to dissapear this status bar / notification bar so that the user (theft) can't access that device anymore..
Please help me to solve this..
I think what you're trying to do is programmatically set an activity as fullscreen. If so, consider the following:
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
Source: http://www.androidsnippets.com/how-to-make-an-activity-fullscreen
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().requestFeature(Window.FEATURE_NO_TITLE);
}
requestWindowFeature(Window.FEATURE_NO_TITLE);
only disables the activity's title bar, not the notification bar at the top.
Use this theme in android manifest for your activity :
"Theme.NoTitleBar.Fullscreen"
did work for me.
It hides the notification bar.
On Android 4.0 and lower
Option 1:
<application
...
android:theme="#android:style/Theme.Holo.NoActionBar.Fullscreen" >
...
</application>
Option 2:
public class MainActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// If the Android version is lower than Jellybean, use this call to hide
// the status bar.
if (Build.VERSION.SDK_INT < 16) {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
setContentView(R.layout.activity_main);
}
...
}
on Android 4.1 and Higher
View decorView = getWindow().getDecorView();
// Hide the status bar.
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
// Remember that you should never show the action bar if the
// status bar is hidden, so hide that too if necessary.
ActionBar actionBar = getActionBar();
actionBar.hide();
And for Android 4.6(Api 19) and higher use the Immersive Full-Screen
Mode
Reference from Google
Related
I want to disable incoming call and text notification and use my app to show notification.
Logic is that my app will stay in background and on incoming call/text my app will popup with a page where I will show notification.
Please can anyone help me how Can I disable default incoming call/text notification.
I was able to hide incoming call notifications by using full screen activity.
incoming call notification is not visible only activity is visible.
obviously you need to create service to detect incoming call which will launch your activity.
Here is code I used for full screen activity
protected void onCreate(Bundle savedInstanceState) {
this.getWindow().getDecorView().setSystemUiVisibility(getSystemUiFlags());
setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
super.onCreate(savedInstanceState);
if (Build.VERSION.SDK_INT < 16) {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
setContentView(R.layout.myviewxml);
}
the function
private static int getSystemUiFlags() {
return View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
| View.SYSTEM_UI_FLAG_IMMERSIVE
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN;
}
The manifest entry
<activity
android:name=".MyActivity"
android:label="#string/title_activity"
android:theme="#style/Theme.AppCompat.Light.NoActionBar"></activity>
Hope this helps somebody.
I'm using Cordova's StatusBar and SplashScreen. I want the app to launch fullscreen i.e. status bar to be hidden when the app launches.
In the deviceready callback, I'm invoking StatusBar.hide() and later on I use StatusBar.show() to show the status bar again. This works fine.
The issue is when the splash image appears, the status bar is visible. And when the deviceready callback if fired, the status bar hides. I even tried setting Fullscreen preference in config.xml to true, but the result is same. Hide at Startup configuration is also related to iOS only.
Is there a way (using Cordova only) to launch the app without status bar and show it later on?
Note: I'm using SplashScreen plugin to show splash screen
Find MainActivity.java in
\platforms\android\app\src\main\java\com\yourpackage\name
add this to the import section :
import android.view.WindowManager;
then add this code to the last line :
public class MainActivity extends CordovaActivity
{
#Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
// enable Cordova apps to be started in the background
Bundle extras = getIntent().getExtras();
if (extras != null && extras.getBoolean("cdvStartInBackground", false)) {
moveTaskToBack(true);
}
// [Hyuck] add this two line below
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
// Set by <content src="index.html" /> in config.xml
loadUrl(launchUrl);
}
// [Hyuck] onStart() is totally new.
#Override
public void onStart()
{
super.onStart();
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
}
}
this is snippet from Hyuck answer on :
Ionic 3 - Hide status bar during splash screen show
it's do the job for me.
I knew this question is being asked previously but not getting the accurate solution.
I want to hide ActionBar and NavigationBar from my activity in or order to make it full screen. I tried the below code in my Activities OnCreate Method but its showing Action Bar for some fraction of seconds and than making it full screen. In Galaxy S3 (android 4.3), its even more than a second. so how can I make it completely invisible and my activity as full screen completely from the beginning only.
I saw many apps running on S3 only, but their is no ActionBar, not even for fraction seconds.
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_main);
if (Build.VERSION.SDK_INT < 19) {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
} else {
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);
}
}
In the onCreate function of your activity add this code before setContentView:
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
In AndroidManifest file write
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
If the minimum SDK Version of your application is 19 (KitKat), then you have to add an additional piece of code to your onResume function:
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 );
In AndroidManifest file write
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
in activity tag
and use
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
befor setContentView(R.layout.activity_main);
Try android:theme="#android:style/Theme.NoTitleBar.Fullscreen" in the declaration of your Activtiy in your Manifest.
try this before setContentView
//Remove title bar
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
//Remove notification bar
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
This Android Developer and This Post demonstrates Immersive Full-Screen Mode which allows your app to go full screen.
tltr;
try this snippet which I got from the Android Developer website:
View decorView = getWindow().getDecorView();
// Hide both the navigation bar and the status bar.
// SYSTEM_UI_FLAG_FULLSCREEN is only available on Android 4.1 and higher, but as
// a general rule, you should design your app to hide the status bar whenever you
// hide the navigation bar.
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
Hopefully I helped!
i think you have to write just
getActionBar().hide(); (Above Api level 11)
or
getSupportActionBar().hide();(Up to Api level 8)
thats it...
This question already has answers here:
is it possible to hide the system bar
(5 answers)
Closed 9 years ago.
I am developing an application for tablet only, where the requirement is to run the app on the full screen of the tablet.
So please help me how to hide the tab bar because that apps is totally related to examination.
So back press, home and and other buttons are not required..
You cant hide that. How should a user quit your app without the bottom bar?
You can hide the bottom bar. But there is no direct method available. First you need to root the tab and then run the process to hide the bar. If you root the tab then the warranty will be void. And there is no unique method to root the tab (getting super user privileges), different tabs have different methods. And once you have rooted the tab, then you should do
//hide status bar
process = Runtime.getRuntime().exec(new String[]{"su","-c","service call activity 79 s16 com.android.systemui"});
process.waitFor();
//show status bar
process = Runtime.getRuntime().exec(new String[]{"am","startservice","-n","com.android.systemui/.SystemUIService"});
process.waitFor();
But this will work only for HoneyComb. For ICS and above try to find the code to hide status bar.
You can try below approach.
public class ActivityName extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// remove title
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main);
}
}
Or you can do it via your AndroidManifest.xml file:
<activity android:name=".ActivityName"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen">
</activity>
I created a launcher, to use it in an internal application. for some security reasons i would like to hide the system bar (the acces to the parameter an ordrer to the acces to installed application). But i have no idea how to do this.
Tablet that will be used are not rooted.
Can you help me please?
You can't hide it but you can disable it, except home. For that you can give your application as home category and let the user choose.
<category android:name="android.intent.category.HOME" />
Rest all can be disable.
add this in manifest.
<uses-permission android:name="android.permission.EXPAND_STATUS_BAR"/>
inside onCreate()
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_home);
View v = findViewById(R.id.home_view);
v.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
where home_view is the parent view of xml file.
#Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
return false;
}
public void onWindowFocusChanged(boolean hasFocus)
{
try
{
if(!hasFocus)
{
Object service = getSystemService("statusbar");
Class<?> statusbarManager = Class.forName("android.app.StatusBarManager");
Method collapse = statusbarManager.getMethod("collapse");
collapse .setAccessible(true);
collapse .invoke(service);
}
}
catch(Exception ex)
{
}
}
You can hide the bottom bar I used this code to hide:
getWindow().getDecorView().setSystemUiVisibility(View.GONE);
use this code for android box with keyboard or remote.
Tablet that will be used are not rooted
Then you can't hide it. You can however use SYSTEM_UI_FLAG_HIDE_NAVIGATION to hide it temporary, but it will get visible once the user touches the screen:
There is a limitation: because navigation controls are so important,
the least user interaction will cause them to reappear immediately.
When this happens, both this flag and SYSTEM_UI_FLAG_FULLSCREEN will
be cleared automatically, so that both elements reappear at the same
time.
You can hide the navigation bar on Android 4.0 and higher using the SYSTEM_UI_FLAG_HIDE_NAVIGATION flag. This snippet hides both the navigation bar and the status bar:
View decorView = getWindow().getDecorView();
// Hide both the navigation bar and the status bar.
// SYSTEM_UI_FLAG_FULLSCREEN is only available on Android 4.1 and higher, but as
// a general rule, you should design your app to hide the status bar whenever you
// hide the navigation bar.
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions
See the following: Hiding the Navigation Bar
Put this in your onCreate() method:
requestWindowFeature(Window.FEATURE_NO_TITLE);
EDIT: Hiding the status bar would require your application be full screen or rooted.