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;
Related
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);
}
}
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);
}
}
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);
}
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.
I was just adding a log out button in the action bar. It worked in emulator but when i install that apk in mobil the log out button is absent.
It works perfectly when i use emulator to test but not in real device or mobil its not working.please can anyone help me with this ? I have spent whole day on this but could not figured out what is happening. Its being an emergency please anyone . Thanks in advance.I have tried following code:
private android.app.ActionBar actionBar;
actionBar = getActionBar();
// Hide the action bar title
actionBar.setBackgroundDrawable(new ColorDrawable(Color.BLACK));
#Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.actionmenu, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Take appropriate action for each action item click
// Toast.makeText(MainActivity.this, item.getTitle(),
// Toast.LENGTH_LONG).show();
switch (item.getItemId()) {
case R.id.action_refresh:
// refresh
Intent intent = new Intent(Autofill.this, Main.class);
startActivityForResult(intent, 0);
return true;
default:
return super.onOptionsItemSelected(item);
}
}
R.menu.actionmenu.xml file contains :
<item
android:id="#+id/action_refresh"
android:icon="#drawable/ic_launcher"
android:showAsAction="ifRoom"
android:title="#string/action_refresh"/>
<!-- Help -->
The option is positioned if there is room, so ...
You could change ifRoom with always
Other options:
["ifRoom" | "never" | "withText" | "["ifRoom" | "never" | "withText" | "always" | "collapseActionView"]" | "collapseActionView"]