Navbar not getting hidden on specific manufacturer's device - android

I have an Android device with root privileges (out-of-the-box). I am trying to hide the nav bar so the home and back buttons are not visible. I am performing this task using the following:
proc = Runtime.getRuntime().exec(new String[]{"su","-c","service call activity "+ ProcID +" s16 com.android.systemui"});
where ProcID = "42"
This works on my root Samsung Galaxy Tab 2, but does not work on this particular Android device (OS v4.2.2).
Any guidance would be appreciated. There are no errors encountered unless I run this on a non-root device.

Are you trying to make your app running on a full screen like games?
Try using immersive mode sticky. Like:
View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
You can get more info from here: https://developer.android.com/training/system-ui/immersive.html
Hope thats what youre looking for

Related

Start activity when screen is off

I have set up an AlarmManager to start up an activity. This activity also plays a sound, similar to an alarm app or an incoming call.
It works ok if the screen is on, even if the screen is locked.
If the screen is off, it doesn't work at all. I tried using the following as the first thing in onCreate
getWindow().setFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON, WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
If the screenlock is not enabled, this turns on the screen and I can see my activity closing. I can't hear the sound playing. If the screenlock is enabled, the screen won't turn on at all.
Sometimes I get the following, but not always:
07-18 23:52:13.685: E/OpenGLRenderer(14148): GL_INVALID_OPERATION
How can I make it start properly when the screen is off?
I got my answer partially from here.
lock = ((KeyguardManager) getSystemService(Activity.KEYGUARD_SERVICE)).newKeyguardLock(KEYGUARD_SERVICE);
powerManager = ((PowerManager) getSystemService(Context.POWER_SERVICE));
wake = powerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "TAG");
lock.disableKeyguard();
wake.acquire();
getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
| WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
| WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
| WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
| WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON);
A while back I read that your app must be in full screen for the FLAG_TURN_SCREEN_ON to work.
"** One important note. Your activity must be full screen in order for the above flag combination to work. In my app I tried to use these flags with an activity which is not full screen (Dialog Theme) and it didn't work. After looking at the documentation I found that these flags require the window to be a full screen window." -Wake Android Device up
Quote from someone who posted their about a similar issue with FLAG_X.
Look into running a service, activity is going to be stopped when not in foreground.
Also look into the Activity lifecycle. http://developer.android.com/reference/android/app/Activity.html

First touch being ignored?

I'm working on an Alarm Clock. As part of it, I have an IntentService that starts an activity when the alarm actually goes off. In the Activity's onCreate I'm waking up the screen, obtaining wake lock, forcing the activity to full screen, and playing a sound. Here's all that in the onCreate:
super.onCreate(savedInstanceState);
// Get Alarm ID from the extras
Bundle extras = getIntent().getExtras();
int id = extras.getInt("AlarmID", -1);
// Get Alarm info from the DB
DB = new DatabaseHelper(this);
alarm = DB.getAlarm(id);
if (alarm == null || !alarm.isEnabled()) finish();
getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
setContentView(R.layout.activity_alarm);
// My root view
View contentView = findViewById(R.id.fullscreen_content);
// Hide action bar for full screen
ActionBar bar = getActionBar();
if (bar != null) bar.hide();
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
// Hide nav bar
mSystemUiHider = SystemUiHider.getInstance(this, contentView, HIDER_FLAGS);
mSystemUiHider.setup();
mSystemUiHider.hide();
// Show over lock screen
getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
// Wake up screen
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
wakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "MyWakeLock");
wakeLock.acquire();
// Get UI Elements
TextView time = (TextView)findViewById(R.id.Time);
TextView name = (TextView)findViewById(R.id.SmallAlarmName);
// Fill UI Elements
time.setText(Alarm.FormatTime(alarm.getHour(), alarm.getMinute()));
name.setText(alarm.getName());
// Play selected ringtone
tone = RingtoneManager.getRingtone(this, alarm.getSound());
tone.setStreamType(RingtoneManager.TYPE_ALARM);
tone.play();
The view is rather simple: 2x TextViews to show the time and the name of the alarm, and 2x clickable ImageViews for Snooze and Disable.
The problem I'm having is that the first time I touch the screen, nothing happens. Both of the ImageViews start with a Log.i so I know when I push it if the event fires. On the first push, there's no log output. On the second push, the proper ImageView's event is fired. It doesn't matter if the screen was originally on or off when the activity is created, the first touch is very repeatably ignored. What's happening and how can I fix it so that the first touch works as expected?
I'm testing on my Nexus 5, 4.4.3, Rooted, stock rom, Xposed Framework (but no module that would affect my app). I can't really test in a virtual machine because of the need to use ringtones (of which the VM has none).
Also, for the record, no other logs happen for the first tap. I have no clue what the phone thinks I'm tapping.
EDIT: I thought it had something to do with the flags. I noticed that I was calling setFlags instead of addFlags in my call getWindow().setFlags(...). Instead, I changed it to addFlags and tried changing it to:
int flags = WindowManager.LayoutParams.FLAG_FULLSCREEN |
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON |
WindowManager.LayoutParams.FLAG_TOUCHABLE_WHEN_WAKING |
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED;
getWindow().addFlags(flags);
But no change.
Is there a way I can tell what might be intercepting the first tap?
I tried setting a break point at the end of onCreate and continually stepping over until it eventually is awaiting for an event to arise, but even in this state the first tap won't make a change in the debugger. A second tap on one of my ImageViews will, as expected, stop the debugger at the first line inside my click handlers.
EDIT 2: I think I'm on to something. I was watching the logcat through a filter, only seeing things relating to my app. I tried looking at the logcat without a filter and was able to reliably get these kinds of messages on first tap:
06-12 23:28:04.437 812-844/? W/InputEventReceiver﹕ Attempted to finish an input event but the input event receiver has already been disposed.
The first tap would respond with two of these warnings. Additional taps after the first would give no such warning and my handlers would execute as expected.
A quick search came back with this question but is unhelpful for my situation. More than just a warning, I think this may be the root cause for why the first tap is ignored. However, I still don't have any idea as to how to fix it.
Not sure if this is even answer or how much universal it is, but.. I somehow managed to solve this issue for me by removing these flags:
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
//| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
//| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
I can only speculate about reason why those 2 flags caused ignorance of the first touch. Maybe it is the "Immersive mode" correlating with these tags, bacause it should (and does) hide navigation by itself, so maybe it conflicts under the hood somehow.. I don't know :-)
I eventually came across this question which linked to this answer.
I ended up moving this block of code:
int flags = WindowManager.LayoutParams.FLAG_FULLSCREEN |
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON |
WindowManager.LayoutParams.FLAG_TOUCHABLE_WHEN_WAKING |
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED;
getWindow().addFlags(flags);
To just after I acquire wake lock (just before I start filling the views) and added the code in the answer, specifically:
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);
Both of these changes now give me the result I'm looking for: the first input is accepted! My guess is that something in the UI hider or the wake lock acquisition is changing the apps flags. I don't know what to, I don't know which flag is causing my issue. All I know is that by moving this code around, I no longer have to press on the screen twice. I'd love a real explanation for WHY this fixed it but in lieu of that, I'll take this.
I would suggest you put most of the code into onStart() and have the content view set in onCreate(). Another thing I would suggest. Instead of using the android:onClick="" attribute in the layout XML, use a listener and assign it to the button via code. But that's more 'seperation of concerns'.

Unable to remove Navigation Bar - Android Tablet: 4.2.2

I'm attempting to remove the navigation bar programatically using the most commonly found method on the internet - however the navigation bar continues to appear.
I've debugged the method and it is not throwing an exception - so I'm really not sure why we can't seem to hide the Navigation Bar using the following code:
(any suggestions are greatly appreciated)
Source:
try
{
Process proc = Runtime.getRuntime().exec(new String[]{"su","-c","service call activity 42 s16 com.android.systemui"});
proc.waitFor();
}
catch(Exception ex)
{
//Toast.makeText(getApplicationContext
Try doing this, somewhere after you have set your content's view
To hide your navigation bar
View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
To hide your keyboard
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(myEditText.getWindowToken(), 0);
For more on the navigation bar, since it is what your question explicitly asks for, take a look here: Hiding the Navigation Bar

Android Galaxy S4 -- Activity that is visible over lock screen

A few years ago, I wrote an alarm app that worked on Android 2, and I'm now trying to upgrade it to work on Android 4. Specifically, on the Samsung Galaxy S4.
On Android 2, if the phone was sleeping, it would wake the phone up and display a "Snooze or Dismiss" screen over the lock screen.
On Android 4, it wakes the phone up, but you have to unlock it, then open the notifications area, then click the alarm's notification, before you can hit "Dismiss."
I have always been using this code to do the waking:
getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
| WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
| WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
| WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
I have read 8 different stackoverflow questions on this matter. Most of them give the code above, which worked for me years ago in Android 2 but doesn't work in Android 4. But none of them have helped me solve this problem. Here are the questions that I read and tried:
Android: remove or disable programmatically the Lock Screen on Samsung Galaxy S2 device
How to display a fullscreen TYPE_SYSTEM_ALERT window?
How do I create an Activity that is visible on top of the lock screen
How to start a dialog (like alarm dimiss /snooze) that can be clicked without unlocking the screen
Android activity over default lock screen
android device locked, yet want alarm to sound and dialog to appear
Android dialog over lock screen
Show dialog with touch events over lockscreen in Android 2.3
Does anyone have any ideas about what's changed in Android 4 that may have caused this?
EDIT: Here is one of the simplest examples I've seen of an alarm dialog that doesn't come up "minimized." It does not, as written, appear over the lockscreen, but you can fix that with WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
http://wptrafficanalyzer.in/blog/setting-up-alarm-using-alarmmanager-and-waking-up-screen-and-unlocking-keypad-on-alarm-goes-off-in-android/
It's written with a FragmentActivity and a DialogFragment, but it still works as an Activity. It uses an AlertDialog.Builder to make the dialog, and if you try to do it with an XML layout, it won't work. Why?
I figured it out, and the answer was very different from what I expected.
This piece of code was included in the alarm clock sample from Android 2, in the AlarmAlert.java Activity:
#Override
protected void onStop() {
super.onStop();
// Don't hang around.
finish();
}
For reference, you can see the file from the example code in Git's past right here, containing the above onStop function. It never caused a problem in Android 2.
But in Android 4, if the phone was off, this onStop would fire right before the phone woke up, effectively "minimizing" the Activity. Once I removed this function, it immediately worked again.
But I wonder, is this the problem that other people like #radley and #Guardanis are getting? It seems unlikely, but please let me know if this fixes your problems too.
If you're visiting this answer in the future, and you're getting this problem, what I would try is:
Take out any onStop functions.
Add this code to the Activity:
getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
| WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
| WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
| WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
Make sure you're using a full screen theme, and not a dialog theme.
This didn't make a difference for me, but you could try setting showOnLockScreen explicitly in the manifest: <activity android:name="com.example.MyActivity" android:showOnLockScreen="true"/>
A second thing that didn't make a difference for me but you might try is adding the flag WindowManager.LayoutParams.FLAG_FULLSCREEN
I hope this helps other people!
In Kotlin,
For Api level 28 or less, you can simply add below method in your activity that needs to be opened:
override fun onAttachedToWindow() {
super.onAttachedToWindow()
toBeShownOnLockScreen()
}
private fun toBeShownOnLockScreen() {
window.addFlags(
WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
or WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
setTurnScreenOn(true)
setShowWhenLocked(true)
} else {
window.addFlags(
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
or WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
)
}
}
And to make it work on Android Pie and above, in additional to above step, we need to set in AndroidManifest as well:
<activity
android:name=".view.activity.LockScreenActivity"
android:showOnLockScreen="true"
android:showWhenLocked="true"
android:turnScreenOn="true" />
I have tested this code from Api level 21 to 29, and works like charm!
Not sure if this is the problem in all cases, but the documentation on ShowWhenLocked says it applies only to the top-most full-screen window. I had a window themed as a dialog which was not working, but it worked fine once I changed it to a regular full-screen window.
One of the questions you linked to has an answer that appeared to solve this issue for me.
This is the code I am using which appears to be working:
#Override
public void onAttachedToWindow() {
Window window = getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
| WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
| WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
| WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
| WindowManager.LayoutParams.FLAG_FULLSCREEN);
super.onAttachedToWindow();
}
I'm also explicitly declaring this in the activity definition in the manifest:
<activity
android:name="com.example.MyActivity"
android:label="#string/app_name"
android:showOnLockScreen="true"
>
Android activity over default lock screen
Right - So I have been struggling with this one recently but with a 5.0.2 Galaxy Tab A. Unsurprisingly what works on every other device does not work on Samsung (this has been the case since the first Samsung Galaxy device, they break something new each release!)
The general solution for showing an Activity over the lock screen for most devices is
//wake up device and show even when on lock screen
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD |
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON |
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON |
WindowManager.LayoutParams.FLAG_FULLSCREEN);
However this does not work for samsung devices. Removing FLAG_DISMISS_KEYGUARD however does this trick.
Looking at the docs for this flag we have
Window flag: when set the window will cause the keyguard to be dismissed, only if it is not a secure lock keyguard. Because such a keyguard is not needed for security, it will never re-appear if the user navigates to another window (in contrast to FLAG_SHOW_WHEN_LOCKED, which will only temporarily hide both secure and non-secure keyguards but ensure they reappear when the user moves to another UI that doesn't hide them). If the keyguard is currently active and is secure (requires an unlock pattern) than the user will still need to confirm it before seeing this window, unless FLAG_SHOW_WHEN_LOCKED has also been set.
and for FLAG_SHOW_WHEN_LOCKED we have
Window flag: special flag to let windows be shown when the screen is
locked. This will let application windows take precedence over key
guard or any other lock screens. Can be used with FLAG_KEEP_SCREEN_ON
to turn screen on and display windows directly before showing the key
guard window. Can be used with FLAG_DISMISS_KEYGUARD to automatically
fully dismisss non-secure keyguards. This flag only applies to the
top-most full-screen window.
You can see they can be used together but it seems samsung will not bother with FLAG_SHOW_WHEN_LOCKED if the device is locked and FLAG_DISMISS_KEYGUARD is present. My app requires a lock screen to be setup so removing the dismiss keyguard flag actually allows me to show full screen Activities over the lock screen. Yay for me, nay for samsung.

full screen application android

i have two questions:
one how can i run my application in full screen
how video players run videos in full screen.
i have tried alot and still struggling to achieve this but couldn't find a solution.
the list of solution i found but they are not fulfilling my requirements
this hides only the notification bar.
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
also hides only the notification bar
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen">
it low profiles the navigation bar not hiding it.
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
no effect on my activity.
anyView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
note that:
i am not talking about rooting a device,so please provide those solutions which can work without rooting a device.
i am not talking about hiding only notification bar,but full screen by hiding both navigation bar and notification bar too.
i am talking about jelly beans api 4.1 or greater than 4.1 version of android
and please give answers with code.
after my research and your answers, i am getting this:
but my app should look like this without navigation bar:
i do not want the system navigation bar visible in my app.
I'm not sure what you're after, but the following hides the Notification bar, and the Soft Navigation keys (as seen on Google Nexus-devices), so the app essentially is "full screen".
Edit2
In Android 4.4 (API 19) Google introduced the new Immersive mode which can hide the status & navbar and allow for a truly fullscreen UI.
// This snippet hides the system bars.
private void hideSystemUI() {
// Set the IMMERSIVE flag.
// Set the content to appear under the system bars so that the content
// doesn't resize when the system bars hide and show.
mDecorView.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 // hide nav bar
| View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
| View.SYSTEM_UI_FLAG_IMMERSIVE);
}
// This snippet shows the system bars. It does this by removing all the flags
// except for the ones that make the content appear under the system bars.
private void showSystemUI() {
mDecorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
}
Reference:
https://developer.android.com/training/system-ui/immersive.html
Edit:
Tested on Android 4.3 (API 18) and Android 4.1 (API 16) with Soft Nav keys.
#Override
protected void onCreate(Bundle b) {
super.onCreate(b);
setContentView(R.layout.main);
int mUIFlag = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LOW_PROFILE
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
getWindow().getDecorView().setSystemUiVisibility(mUIFlag);
}
For more information read up on http://developer.android.com/reference/android/view/View.html#setSystemUiVisibility(int)
-To hide Status bar:
A great solution I found for that issue, setting each Activity theme & windowSoftInputMode to the following values :
<activity android:name=".MyActivity"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
android:windowSoftInputMode="adjustResize"> <!-- theme : to set the activity to a full screen mode without a status bar(like in some games) -->
</activity> <!-- windowSoftInputMode : to resize the activity so that it fits the condition of displaying a softkeyboard -->
for more info refer here.
-To hide Notification bar:
There are Two ways :
1- root your device, then open the device in adb window command, and then run the following:
adb shell >
su >
pm disable com.android.systemui >
and to get it back just do the same but change disable to enable.
2- add the following line to the end of your device's build.prop file :
qemu.hw.mainkeys = 1
then to get it back just remove it.
and if you don't know how to edit build.prop file:
download EsExplorer on your device and search for build.prop then change it's permissions to read and write, finally add the line.
download a specialized build.prop editor app like build.propEditor.
or refer to that link.
On the new android 4.4 you should add this line:
View.SYSTEM_UI_FLAG_IMMERSIVE;
So the new working solution atleast on nexus4 4.4.2 is
final int mUIFlag =
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LOW_PROFILE
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_IMMERSIVE;
Immersive alone won't work though it works when combined with other flags. see documentation for more details.
Then you add in the activity the activating of this setup as shown here before (I am just adding for consistency)
getWindow().getDecorView().setSystemUiVisibility(mUIFlag);
I made 2 layouts one for regular size and one for full screen and inside full scrreen I get the devices size and and assign it to video player
Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getRealSize(size);
int w=size.x;
int h=size.y;
videoPlayer.setFixedSize(w, h);
I think you cant hide the system bar in android 4.0 > (only in tablets, in phones you should be able to)
What you can do is to hide the icons and to disable some buttons(everyone except home)
You can try this:
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
}
Also for disabling the buttons:
This is for back button:
public boolean onKeyDown(int keyCode, KeyEvent event) {
return false;
}
This for the menu:
#Override
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)
{
}
}
Video Players run in full screen by setting the
myView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
setFlags() before setContentView(View)
This will show the system bar on any user interaction, just like video players do.
The closest you can get to running your app full screen is by setting in Lights Out mode, the system buttons will appear as dots.
To use the lights out mode just use any view in your activity and call
anyView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
For Hiding the navigation bar use this in your onStart() so that every time you get to that activity it will be in full screen mode.
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
I hope this helps !
Android Version: 4.2.2 - Device: Vega Tablet
Android App to Hide Status and System Bar and displaying complete screen I followed these steps.
AndroidManifest.xml
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name">
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
MainActivity.java
super.onCreate(savedInstanceState);
getWindow().getDecorView().setSystemUiVisibility(0x10);
setContentView(R.layout.activity_main);
Above code perfectly worked for my app.
go to your manifest and add this to your activity
<activity
android:name="yourPackage.yourActivity"
android:theme="#android:style/Theme.Black.NoTitleBar">

Categories

Resources