Implementing back, home and recent apps button for android - android

I'm making a custom my own navigation bar which will have back, home and recent toggle apps. I'm not using the android provided buttons. I just want to make my own. I made the code for home and recent apps button but could not find code for back button. Anyone knows how to do it. Please, its been a week and I'm tired searching about it and nothing seems to work at all. I know its too much to ask but if you have the code to implement the back button for custom navigation bar, please post it. I desperately need help.
Thank you

Related

Android studio navigation drawer crash on press

I have made a navigation drawer with Kotlin in Android Studio. When I launch my app to my phone it works like it should. But when I press the actual drawer, the app crashes. I do not know what I miss or have not made correct to make it work. If there are sertain files you need to see please let me know and I'll give it. I have tried searching on the internet but I've not come any further.
I have made an main_nav_drawer.xml file and a main_toolbar. Do I miss something here?

Disabling home button Android

I have read a lot about how we cannot override or disable home button. And I too agree that its risky in many ways as some people might take wrong advantage of it. But unfortunately its a requirement in my app.
I was able to hide them in my device which runs on Android Kitkat using the Immersive feature. Its true that when user swipes from the edge of the screen it makes the status and navigation bar visible. But I found out a way to disappear it again by calling Immersive every second or so using CountDownTimer. The result was satisfactory and got the job done.
But I do not have any solution for Android devices which does not run on Kitkat as the bars appear every time we interact with screen. Even though the bars hide but appearing every time the user touches the screen does not look good. So Immersive feature is out of question since it does not run except for Kitkat.
I did try out another solution suggested in various SO posts -
Making my activity visible when the screen is locked. This helped me to get rid of the third button (button right side of Home button, not sure what it is called). And we could easily handle back button. But still home button is remaining. I need to somehow make this Home button disable or do nothing. Or atleast (worst case scenario) navigate to my app when ever I click on home button (Is it possible?)
What I am looking for is the user should only be able to leave the app from a button which I have provided in my app, there should'nt be any other way. Can someone suggest me a way to achieve this?
I am on a deadline here. Any help on this will be helpful to me greately. I am also open for other ways of achieving the above nonesense feature.
Thanks :)
Android 5.0 introduces a new screen pinning API that lets you temporarily restrict users from leaving your task or being interrupted by notifications. Once your app activates screen pinning, users cannot see notifications, access other apps, or return to the home screen, until your app exits the mode.
https://developer.android.com/about/versions/android-5.0.html
I was interested on this subject, and a topic discussing the same was release weeks ago. the conclusion is on older versions exists external librarys and/or simple code to implement and override home button.
On +4.0 i dont think so. check this topics: Disable Home button in Android 4.0+ and https://stackoverflow.com/a/10025904/3640637
hope it helps.
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.HOME" />
Add this to your activity in the manifest.
I think would be better for you to change your approach. If you want to make something which never will be closed by Home button, just make service and add a view to the Window Manager. With the Layout params you will be able to draw on top of everything that even home button won't close it. Life sample could be Facebook messengers new chat.
You can make 2 services. One to cover status bar layer and another one to cover the other part of the screen. Please have a look at this samples
Overlay Status bar on android 4.2.2+
http://www.piwai.info/chatheads-basics/
I have tried to block Home button with the sample below, but this blocks only HARD home button
- https://github.com/shaobin0604/Android-HomeKey-Locker
Your explanation helps only for the newer versions. So just combine or take the first one to achieve that. Good Luck :)
If people here have some other good approach, then I would like to hear that, because it is interesting for me.

Method that makes action bar comes up again when hidden

I'm devolopping a tablet app. I want it to work full screen. After days of investigeting on google, I achived it using:
.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
.getWindow().getDecorView().setSystemUiVisibility(Window.FEATURE_ACTION_BAR_OVERLAY);
.getWindow().getDecorView().setSystemUiVisibility(Window.FEATURE_ACTION_MODE_OVERLAY);
The Tablet I'm using is 4.1 Android version. That was working perfectly though I had to made some changes like doing my own action bar (because sistem action bar made navigation buttons comes up) and dialogs.
Now the problem is that I've installed my application on 4.2 Android version and it's a disaster. Each time I touch the screen, navigation buttons comes up. It's really annoying. This is driving me mad, I've tried many things but it's still coming up.
Is there a way to solve this problem? I think if I could override the method that makes navigation buttons comes up I could achieve my objective. Anybody know which is this method??
It is not working in 4.0 Android version neither. That doesn't bother me much, but if you know a way to solve it as well, that would help me a lot.
I would appreciate any help. Thanxs a lot.
Each time I touch the screen, navigation buttons comes up.
One of the core Android concepts is that the user is always in control of the UI. If developers were allowed to create fullscreen Apps and override the navigation buttons, it would be trivial for an App (rogue or otherwise) to create a screen which the user could not get out from.
If you really want to remove the system bar, you will system-level access or you need to build your own custom Android.

Porting Android to BB: When clicking the "Info" button, the app crashes

Recently we ported successfully an Android application on BlackBerry 10.
Everything worked fine, except the thing that when clicking the "Info" button from the action bar that appears at the bottom of the screen - the application crashes.
I suppose that button should display an About, or Help page. We do have in our application a such page (as an ActionItem in the ActionBar).
Does anyone know if there is a way we can fix this, so that when clicking the "Info" button to display our About page? Or at least to do something to prevent the app from crashing, for example hide that button.
Thank you.
I posted this question on BB developer forums, and got a pretty good answer:
This is actually a known issue in the current Android Runtime on the
BlackBerry 10 simulator release. It has nothing to do with your
application, as this action bar is part of the Android Runtime and not
your application. Normally when you section the "Info" button you
would see a screen showing you have to use the back swipe gesture used
in Android Runtime applications. If you wanted your own About button, you would have to create your own menu.

How to call the Shortcut menu like a long press on the home screen

Im tyring to figure out how to bring up the shortcut assign menu (the menu you get when you long press the screen for the Home launcher. I cant seem to find anything on this and need to make shortcuts for both applications and be able to do direct dial and saved navigations.
It's called a ContextMenu. See here for how to add ContextMenu to your applications. Not sure if this is what you're looking for though.
To add a Shortcut to the Androids home-screen, you can use some of the code provided here.
I'm not sure how to do this for the Dailer or Google Maps, but here is an example of how to do it for the Browser. It might help you.

Categories

Resources