Android - Removing home and navigation button - java

I'm trying to remove the Home button and the Multithread button. The idea is to remove it completely from the running application, better if we can remove it completely from every application on the tablet we are working with. Using full-screen is not something that we want, since the user shouldn't be able to exit the full screen mode, even if he wants it (it's a custom commercial app, it's the desired behaviour for multiple reasons).
This is the result on a Nexus 10. We accomplished that by taking the SystemUI sources and changing them before compiling the CyanogenMod.
Unfortunately we have to replicate that in an Asus ZenPad 10, that has no CyanogenMod available. We have a version that allows us to create system applications, but change every application into a system application is not something that we want.
We have found in this link: http://developer.oesf.biz/em/developer/reference/eggplant/constant-values.html#android.view.View.STATUS_BAR_DISABLE_HOME
That there are flags for disabling the home button and the navigation button, but they are usable only with system applications.
We have tried to get the SystemUI.apk already compiled in the tablet, decompile it and change it. The problem is that or we have useless smali files or with have only res/ and AndroidManifest.xml files (Asus changed the SystemUI.apk into two apks of it own).
So... we are a little desperate here ahah. Looking for hints / ideas to try to remove that buttons. Better without recompiling or doing some strange thing.

This is possible using a combination of permissions like Immersive Full-Screen Mode combined with the SYSTEM_UI_FLAG_HIDE_NAVIGATION and SYSTEM_UI_FLAG_FULLSCREEN flags. These flags hide the navigation and status bar, now that you have a blank screen put a linear laoyout at the bottom of the screen with only the back icon visible, just to create the effect of what you want. ALSO note that it is important to understand that once the user swipes upwards the normal navigation bar will be visible(not sure if it can be handeled through intercept touch event).
Alternatively you can try out this solution mentioned here also
How to disable Home and other system buttons in Android?
also refer this github project(works if there is only a hardware navigation buttons)
https://github.com/shaobin0604/Android-HomeKey-Locker
Last But not the least There is an answer by commsware that throws more light on this subject might come in handy.
Not able disable Home button on specific android devices

Try Android for work APIs and refer here.Using this apis you can get full control of the device and disable whatever you want.The device can be used only for single app.
Corporate-owned, single-use (COSU) is a subset of the corp-liable scenario for shared or special-use devices. Unlike corp-liable devices that are associated with individual employees, COSU devices are associated with particular business functions. For example, a COSU device might be used as a kiosk.
You can also try to integrate custom MDM(Mobile device management) solution provided by OEMS/MDM vendors/MDM partners like Samsung, HTC, Airwatch etc. This work on devices prior to lollipop too and provide more APIs to control the device than provided by default android solution.
I know Samsung MDM/Knox solution is good and it has APIs to control each and every part of the device.Refer- http://www.samsung.com/levant/business/solutions-services/mobile-solutions/security/mobile-device-management.They have Kiosk mode which is similar to COSU.

You will ask permission to the user. In this car this is yourself. Be careful since you will have to implement a way back out of the application.
Reference: disable home
Or you just could buy a case to stick it around, so the buttons won't be visible...

use immerse mode, use this code in onResume() so that everytime you get back to your activity its ran and they are hid
View decorView = getWindow().getDecorView();
decorView.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);

Of course, you can't REMOVE any System Buttons like Power, Volume +/-, Home, Back or Menu. You can only hide or show Home, Back or Menu only when they are virtual(opposite to Solid Buttons).
Meanwhile, hiding the navigation bar is limited. It only can be completed on Android 4.0 and higher. So, if you want to do this, you need to use 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);
And, if you want to set your application's content to appear behind the navigation bar, you need the SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION flag. You may also need to use SYSTEM_UI_FLAG_LAYOUT_STABLE to help your app maintain a stable layout.

i have tried the same for a long period of time and searched a lot
but as you know the HOME button is the only way for user to get out from
any app in any situation. its very risky to block that and google will not allow it.
One thing you can do is set your application as a launcher application then u can receive keyevent Home

Related

How to open little popup menu for selecting wifi in android?

I noticed this half screen wifi selection menu in some Android Apps.
I would like to use this menu in my own app, to give the user the possibility to select the wifi without jumping to settings app.
I didn't find any instruction how to do this. However AndroidStudios Layout Inspector showed me that its belonging to the system, not to the app.
Anyone knows how to open this menu ?
It's called a Settings Panel:
https://medium.com/google-developer-experts/exploring-android-q-settings-panels-d308525b8345
You are looking for Settings Panel
This is for Android Q.
Here's an example to how to call it.
startActivityForResult(Intent(Settings.Panel.ACTION_INTERNET_CONNECTIVITY), INTERNET_SETTINGS_REQUEST)

Android autolink links always start browser

I'm working on an Android application with an activity dedicated to a webview. I also have a chat section of the app that autolinks web links in the messages. I've created a onItemClick listener on the chat messages to start the webview activity. This listener works when I click the whole chat bubble, but I noticed that if I only click the highlighted link in the message, the listener isn't called and instead my default browser is loaded up.
I put a log message in front of every instance of an intent with ACTION_VIEW, thinking that some other part of my app may be launching the browser, but it doesn't seem like this is the case.
I'm wondering if android has any default methods that catch autolink urls and starts the browser that I could override. Otherwise, I was thinking that I could turn off autolink and imitate the appearance of links with the blue text and the underline, but this seems like a poor solution.
Thanks ahead for any tips on how Android works!
I encountered this situation too, where I have autolink set up in TextViews to automatically handle URLs in TextViews. However, the default behavior is to open the web page in an external browser, so how do we make it open in a webview activity (for example)?
Beneath the hood, this is handled for TextView by LinkMovementMethod. However, the behavior is difficult to customize. There is a 3rd party enhancement over LinkMovementMethod, known as BetterLinkMovementMethod, described in more detail in this blog post. With just a few lines of code changes, the TextView autolinks can be made to open in your webview activity (and clearly, all kinds of other behaviors can be customized as desired).

android is there a way to take screenshot of home and other apps that are not yours programmatically?

I already made a button to be overlaid in the system window, only thing is I don't know how to take screenshot programmatically from that button to take screenshot of home screen or any other screen (not my activity).
What I want is how to programmatically run the combo keys to initiate the screenshot? (like pressing both power and volume down key at the same to take screenshot)
I know using adb command required root (which I don't want to), you can using getrootview but only inside your own activity (which I don't want to).
Since Android Lollipop (5.0) you can use MediaProjection to take screenshot.

Can you remove the system bar (back, home, recent apps) without making an app fullscreen so the notification bar is still accessible? (4.x)

Creating a hardware device that will be running a custom version of Android (4.x). There will be additional functionality incorporated but we would like to use as much of existing Android as we can.
The device will only run one specific app at the start, then plan is to create our own custom system bar / action bar with fragments at the bottom of the screen. However, we ideally want the notification bar to stay at the top of the screen with all of its drop down goodness.
I am aware there are currently two mechanisms that address this:
Temporary absolute full screen hides the system bar until the screen is touched.
Dimming of the system bar where the system bar icons fade to black but still occupy the same space and come back when pressed.
Any help would be much appreciated,
Cheers
EDIT: I know it can be done by changing the source code, that is not possible in the timeframe though unfortunately
I know you can get rid of both the system bar and the notification bar by setting the app to full screen and if we could have that plus the notification bar that would be great.
You can't actually. You have a SYSTEM_UI_FLAG_HIDE_NAVIGATION that hides it, but the bar reappears whenever there is any interaction on the screen (the notification bar also reappears with this).
Seeing as you are looking to replace the system bar completely, you will have to do this at a source code level. You are only allowed to hide it during periods of interactive inactivity using the SDK
You have to create your own version of SystemUI application, and build Android with that version in place of default:
https://github.com/android/platform_frameworks_base/tree/master/packages/SystemUI
If I understand correctly, you can just add this in your manifest xml:
<activity
...
android:theme="#android:style/Theme.NoTitleBar" >
...
</activity>
This will keep the notification bar without going all-out full screen.

Can The Application Icon in the Built In Search Dialog Be Clickable?

Is there anyway to capture when the user clicks on the application icon in the built in search dialog? Please note I am NOT referring to a custom dialog but to android built in search dialog.
Nope, there is no way to make the SearchDialog's app icon clickable.
But just for fun, let's assume there existed some hacky workaround that would get the job done. Cool, we have got the desired behavior... but now we have two issues:
The behavior of the SearchDialog is not consistent with other Android devices. This lessens the user experience since users expect search interfaces to work the same on all Android devices.
Your app now makes use of the internal APIs, which may or may not remain consistent when new SDKs are released. For all you know, the Android team could change the app icon's id from #+id/search_app_icon to #+id/search_home_icon. Your hack depends on the internal APIs... so such a change will cause newer devices running your app to crash (as any runtime search for search_app_icon will return null).
Further, companies like Samsung and HTC are free to alter the internal APIs before they release their new devices to the public. The next Samsung Galaxy could potentially completely re-implement the SearchDialog class, update its UI/theme, etc... you can never know for sure.
So basically, you can't... and you shouldn't make an attempt to do so.
Just because I'm bored, here's the source code that led me to my answer:
Check out the source code for SearchManager.java, and notice that the SearchManager keeps the SearchDialog as a private instance variable mSearchDialog.
Check out the source code for SearchDialog.java, and notice that the SearchDialog references the app icon as the private instance variable mAppIcon. Also notice that the SearchDialog initializes the variable through a call to findViewById, as seen here.
Check out the source code for search_bar.xml and notice that the ImageView is not set to clickable by default. Since there are no (methods in the public SDK that alter the behavior of this View, there is no reliable way to make it clickable.
I'm sure it's impossible to do this using the Android's public SDK.
I think the only solution is write your own custom dialog, but I'm affraid that with the built in dialog you can't accomplish this.

Categories

Resources