How to block navigation bar/status bar android java - java

How to block the navigation bar in android from my app. My app must haven't take the chance go to the settings and other components.
This code on Kotlin
I block the action bar by: window.addFlags(WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY) window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN)
In the photo it is the red zone, I can to override back-button and home-button (I make my app as a launcher for android) and I have did this.
But the main problem - is the button of multitasking - green zone.
The overriding method onUserLeaveHint not solve my problem.
How to remove this button or hide the navigation bar?

I have used below code for hiding the navigation bar & status bar in activity.
#Override
public void onWindowFocusChanged(boolean hasFocus)
{
super.onWindowFocusChanged(hasFocus);
View view = getWindow().getDecorView();
if (hasFocus) {
view.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOU _STABLE
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
);
}
}
In one of My Custom camera app i have used this which shows the full screen camera view witout notification bar & status bar and when you drag from top or bottom then it will show you.
Happy Coding... :)

Please refer this example.
in which shown how to disable :
[Click here][below]
https://github.com/mugku/Android-LockScreenSample-DisableHomeButtonKey
Its tricky part pelase have h deep dive into this.or please check other lock screen example or locker apps. in which screen lock screen has this code.

#Override
protected void onPause() {
super.onPause();
if(SettingsProvider.loadPreventOverviewButtonMode(this)) {
ActivityManager activityManager = (ActivityManager) getApplicationContext()
.getSystemService(Context.ACTIVITY_SERVICE);
activityManager.moveTaskToFront(getTaskId(), 0);
}
}

Related

Recognize whether TalkBack is enabled or disabled

I hide the navigation bar, however, when a blind person uses the app and TalkBack is activated on their smartphone, the blind person cannot exit the app because TalkBack does not allow a drag finger. How to create a function from these two methods to check if TalkBack is disabled on the phone and then the navigation bar is hidden or if the TalkBack option is enabled, hiding the navigation bar is not disabled. Thanks for your help.
#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_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
}
}
AccessibilityManager am = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);
if (am != null && am.isEnabled()) {
List<AccessibilityServiceInfo> serviceInfoList = am.getEnabledAccessibilityServiceList(AccessibilityServiceInfo.FEEDBACK_SPOKEN);
if (!serviceInfoList.isEmpty())
return true;
}
return false;

Android nav Bar ist overlapping Media Controller in Full Screen Mode

I've made a little fullscreen media player in Android Studio. When I tap on the media player in portrait mode, the media controller comes up. But: The navigation bar at the bottom also shows and overlaps the controller.
Do anyone know what I can do against that?
Thanks for help.
PS: Sorry for my bad english... If you can't understand something, just write a comment :D
You can make the view fullscreen (hiding the navigation and status bars) by adding this to your MediaController Activity:
#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);
}
}

[Android]Show status bar and navigation bar programmatically while in Immersive sticky mode

I use the following code to enter Immersive sticky mode in Android.
mDecorView.setSystemUiVisibility(
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_STICKY);
What I want is: I want the status bar and navigation bar to show when I touch the center part of my Activity instead of swiping from the edge. Is that possible?
If you don't want to write any additional code (just call some methods) then use SystemUIHelper from here: https://gist.github.com/chrisbanes/73de18faffca571f7292
and then something like this:
...
SystemUiHelper uiHelper;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.[Your content view]);
uiHelper = new SystemUiHelper(this, [Your flags/modes]);
// Then set onTouchListener on youк root view
// and when someone touch it you will receive an event about it
// and will be able to manage it and hide/show app's UI again
}
#Override
public boolean onTouchEvent(MotionEvent event) {
switch (event.getAction()){
case MotionEvent.ACTION_UP:
if (uiHelper.isShowing()){
uiHelper.hide();
}else{
uiHelper.show();
}
break;
}
return super.onTouchEvent(event);
}

Hide virtual buttons after they are shown again

I found out, that I can hide the virtual buttons of an android phone with:
this.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
But once the user makes them visible by swiping from the edge, they stay visible.
How can I hide them again after a moment ?
Thanks in advance!
Edit:
I start a new activity.
When this new activity is started I call this in the onCreate-Method to hide the actionbar and the virtual buttons:
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
this.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
Edit:
#Override
public void onSystemUiVisibilityChange(int visibility) {
if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) {
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN);
} else {
}
}
This is what your doing:
https://developer.android.com/training/system-ui/navigation.html
This is what you also want to be doing:
https://developer.android.com/training/system-ui/visibility.html
So basically, when you hide an item, you need to listen (check) whether it's been changed (Turned On/Off) and from there re-enable it. I would copy/paste the code, but it's in those links.

Stop the sliding screen at the middle

HomeActivity.java
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.home);
Button btnopen = (Button)findViewById(R.id.btnWindowAnimation);
btnopen.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent slideactivity = new Intent(HomeActivity.this, CartActivity.class);
Bundle bndlanimation =
ActivityOptions.makeCustomAnimation(getApplicationContext(), R.anim.animation,R.anim.animation2).toBundle();
startActivity(slideactivity, bndlanimation);
}
});
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.layout.home, menu);
return true;
}
HomeActivity has a button and it will help to slide the 1st screen and bring the second screen.
animation.xml
android:fromXDelta="100%p"
android:toXDelta="25%p"
android:duration="5000"
This animation code is helping me to slide my screen after pressing the button. As shown in this video
https://www.youtube.com/watch?v=EzgGGWpRES0
I want to stop the new screen at the middle without covering the 1st screen completely.
Any suggestions? I have used another activity called cart( i haven't used fragments here)
Sounds like you want a NavigationDrawer.
You can find out more information on the Android developer site:
https://developer.android.com/design/patterns/navigation-drawer.html
https://developer.android.com/training/implementing-navigation/nav-drawer.htmlA
Your Requirement is to partially Display an Overlapping Activity on an Existing Activity. This is Possible with Sliding Menu Library (Which does not mean to technically create a floating Activity, but to create a Floating View integrated within the Sliding Menu that will be displayed partially on top on an Activity).
In case, if you are regarding this as some sort of Default Menu then please take a look at this Image
If this is your actual Requirement, then here are the details for you.
Sliding Menu Library is an OpenSource Library, you can use it for displaying a partially visible Sliding Menu on top of an Activity.
Here is the link of Sliding Menu Lib :
https://github.com/jfeinstein10/SlidingMenu
You can navigate to the example directory present in this Project for the demonstration of it's Usage.
I hope thie helps :)

Categories

Resources