[Q] Home button event - Android Software Development

I thought this topic might have ever been discussed before.
However, I tried to search the solution in the site but none of any i found. Prob I missed something.
I was tring to override the home button event. What I intended to do is to block the home button event(return back to the main page of default Android) and run my launcher home instead.
For example, if you wanna do the button test application on any android based device, home button needs to be handled.
Eventhough Android official website has announced that the developer is unable to override home button event, I still notice that some developers has completed this activity.
What I found so far is some developers add
<meta-data android:name="android.dock_home" android:value="true"/>
this line into their Androidmanifest and they say that's all they did for blocking the original home page.
I did the same procedure, however, it did not work well on my side.
Probably some of you have the experience on hadling this matter. Please share your experience so that I can follow up to get this issue done.
Any reply is appreciated.
Thanks in advance.

There is an app that remaps keys. perhaps you can take a look at it? You can find it on a post on the desire oxygen rom.
Xda app

You cant override the home button, but you can establish yourself as a replacement for the launcher. If you do that, the user will be prompted with a list of apps that can act as the launcher when they press home

Related

Handling the genius button press

We need to figure out a way to customize the genius button. It would be a great service to everyone, especially if it doesn't require root.
I looked at logCat, and I see that the button fires up the following intent:
Code:
{ flg=0x10000000 cmp=com.nuance.android.vsuite.vsuiteapp/.VSuiteStartSession }
I'm not quite sure how to create an intent handler for something that doesn't have an action or a category. I even created a test app that matches the intent above exactly, but only the stock genius app launches, and I'm not given an option to choose my default handler for the action. I don't think there is a key handler to intercept either. Any ideas
You know, I was thinking about this all morning (eventhough I don't have the device). Back in the day we remapped functions for certain keys (as g1 didn not have search key of any kind). Can someone go into /system/usr and look what's in there? I believe we are looking for keylayout folder. In that folder we should have some .kl files. They named different from device to device (using Cliq now and they are all named MorrisonXXXXX.kl). Look through those files and find genious button function. From there it should be very easy to change it to google search (or voice search) but substituting the function and pushing the file back in its location. I would have no problem doing it but as I said, I don't own the device myself.
Couple more option (highly unlikely to work):
Clear defaults in Genious app
Freeze Genious app
I don't see those working but who knows... we may be able to assign new default after doing this.
kl files
Here are the files from /system/usr/keylayout
Looks like the correct entry is in glacier-keypad.kl, but it is mapped to a "search" function.
Not sure it will help, but I'd love to see search there instead.
I don't mind the genius button, it actually works fairly well the more you use it. However, I don't like that it disables the search button.
It should be single press for search, long press for genius.
That would be perfect.
rjgii said:
Here are the files from /system/usr/keylayout
Looks like the correct entry is in glacier-keypad.kl, but it is mapped to a "search" function.
Not sure it will help, but I'd love to see search there instead.
Click to expand...
Click to collapse
Ok, I'm at work so I can't really do anything with this but I will look into into it later, when I get home. You are correct, it's in the glacier-keypad.kl. Unfortunately, it's set to the same thing as regular search i.e. In G1 we used to set it to SEARCH as well but it would bring up regular search.
I will try to PM GeniusDog (the guy who figured out how to remap keys) when I get home to see if he can give me some insight on this.
Did anyone try to freeze (disable) Genious app to see if it releases G key to regular search?
We should also contact ChiefzReloaded, he would know how to do it since they put CM on Slide which did have Genious on it to begin with.
Ok, so I guess this is a little different then the Slide. Slides G key was mapped to FUNC_4. Our G key already mapped to SEARCH, its just that Genious overtakes it. I twitted Eugene_73 to see if he could help, he was the brain behind Slide's development in this area.
If its helpful to anyone, holding down the menu button will bring out search keyboard. I really wish the would give us a option to chose from the voicesearch ¦,/
Sent from my HTC Glacier using XDA App
borodin1 said:
Ok, so I guess this is a little different then the Slide. Slides G key was mapped to FUNC_4. Our G key already mapped to SEARCH, its just that Genious overtakes it. I twitted Eugene_73 to see if he could help, he was the brain behind Slide's development in this area.
Click to expand...
Click to collapse
Hmm...what about mapping it to a function key (like on the G2) and then assign whatever action we want to that function key? I will try that out as soon as I get some free time.
Alright, so I tried modifying the key layout file on my G2 (vision-keypad.kl) just to test the process and I am not allowed to make any changes. Just get a "Read-only file system" response. I'm sure it would be the same for the MT4G. Anyone have ideas on what else to try? I really want to find a solution without rooting, but any solution would be a good start.
root
We have root now, so we should be able to modify the key mapping files.
If I find any time today I'll give it a shot.
rjgii said:
We have root now, so we should be able to modify the key mapping files.
If I find any time today I'll give it a shot.
Click to expand...
Click to collapse
Great. You will probably have to remount the system partition like this before you can write to it:
su
mount -o remount, rw /system
Oh how I hate that genius button..I would absolutely donate immediately for an app to remap it to search. That would be amazing.
Sent from my HTC Glacier using XDA App
Did anyone try to uninstall (disable) Genious app yet? Since the G key mapped to SEARCH already, this may release it to actuall Google search.... just thinking out loud
I froze it last night. No response from the G button after that.
21productionz said:
I froze it last night. No response from the G button after that.
Click to expand...
Click to collapse
LOL...
They really mean "you" in the commercials!
You gotta customize everything..
Sent From The Moon... With a HTC Glacier
I updated my voice search in the market when I first got the phone, and for a time when I pushed the button is would actually give me the option to choose what app handled the action and I could choose voice search. However, after one time choosing the Genius button it never asked again. I wonder if there would be a way to continuously clear the Default so that it always asked.
borodin1 said:
Did anyone try to uninstall (disable) Genious app yet? Since the G key mapped to SEARCH already, this may release it to actuall Google search.... just thinking out loud
Click to expand...
Click to collapse
I disabled dragon dictation and genius, and after holding the button for a couple seconds, my phone crashed and rebooted. Multiple taps on the button seemed to do the same thing. Leaving dragon dictation enabled and genius disabled seemed to be less prone to crashing.
This has been solved in this thread:
http://forum.xda-developers.com/showthread.php?t=836702

Development of a Tool to Lock Soft Keys (Disabling the Home Key for Games)

--Please move post if not in the correct section---
As far as I can see so far there is no tool/app/hack to disable the soft keys (mainly the home button) for gaming. I imagine all recent soft key phones (HTC Desire HD, HTC EVO, HTC Thunderbolt) suffer from the problems of accidental pressing the home button and throwing you out of the game, losing all progress.
I am surprised that there is nothing I can find that solves this issue (at least not without sacrificing Sense Laucher) and I'd be willing to bet there would be more people than just me that would be willing to pay for this app or tool if it was to be developed especially with all the great games around.
I'm hoping that making this thread might encourage developers to create some tool or app here that could benefit everyone and hopefully be worth their while.
Here's all I can find so far:
When I look at the Android Developer Website I see reference to to KeyguardManager having privileges to disable the home button...
http://developer.android.com/reference/android/app/KeyguardManager.html
public boolean inKeyguardRestrictedInputMode ()
Since: API Level 1
If keyguard screen is showing or in restricted key input mode (i.e. in keyguard password emergency screen). When in such mode, certain keys, such as the Home key and the right soft keys, don't work.
Returns
* true if in keyguard restricted input mode.
See Also
* inKeyguardRestrictedKeyInputMode()
Click to expand...
Click to collapse
So far I've only come across one good post which modifies the specific application you are running (lets say a game) to act as a launcher and then disabling the home button. Here is the post...
Hi,
I found a way to tackle HOME key. For your application set the manifest as:
<action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.HOME" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.MONKEY"/> Now ur application is an alternate Launcher application.
Use the adb, and disable the launcher application using package manager
pm disable com.android.launcher2.
Now the Home key press will always stay in the same screen.
Click to expand...
Click to collapse
I'm not sure what the best method to approach this. I have only extremely limited knowledge of Android. Okay so if the Sense launcher couldn't be modified to disable the home button and we couldn't make another app which acts as a launcher that simply keeps the current app in focus then it might be messy but what about a tool that remakes all apps & games. What I mean is say (failing all else) a tool that batch modifies all apps you set it to modify with the above script and then sets them as acting as the launcher. The issue with this I can see is this method is that I believe it would mean you would need to resign each app or game. I believe current auto signing tools such as the one posted by Stericson only work for around 70% of market apps. You could push the other 30% of the uninstallable/unsignable apps to the system/apps folder but again I think this whole method might only create ongoing problems such as when there is a newer version of the app released then the process needs to be redone...
My guess is there is a better way. Maybe the KeyguardManager could somehow be engineered to disable the home key or the function it performs could be set to another dummy launcher that sit in the background and just to stop sofkey presses?
Okay i've only just tried this out tonight for a couple of minuted but I think it's problem solved! I've just tried out ButtonMapper as a forum memeber has suggested and what do you know, it works!! So happy!! I'm no longer thrown out of a game by touching the home button!!!
I used ButtonMapper 0.2.4 posted on the XDA forums. I couldn't select nothing for the home key so instead I selected "focus" and this seemed to do the job. Great work!! I must give a donation to the developer.
Great news! Do you have a link to ButtonMapper for those of us on XDA app?
Sent from my Nokia 3310 using XDA App
Sure thing buddy
http://forum.xda-developers.com/showthread.php?t=850464

BACK-Button to kill a task *searching*

Hi there,
wondering if there is a way to get the back-button finishing the app.
When i'm at contacts or writing an sms or surfing, i want to go back to desktop as fast as possible...but when i'm at contact/details, i have to press the back button 5-6 times to go back trough all the previous screen.
Is there a way/hack/app telling the back-button (have to be a hardware button) to end the tasks completly when holding it, for example?
THX THX
Press the home button? That will take you back to the desktop.
If you need to you can then use task manager to end the task.
Would be nice to see a hack/fix to add the back button to kill functionality though
IakobosJ said:
Press the home button? That will take you back to the desktop.
If you need to you can then use task manager to end the task.
Would be nice to see a hack/fix to add the back button to kill functionality though
Click to expand...
Click to collapse
I miss this from my oxygen rom'd desire
Pkplonker said:
I miss this from my oxygen rom'd desire
Click to expand...
Click to collapse
It's already in in MIUI and most probably will be also in CM7.
well the back button does kill apps.
if you start, say, the browser and press the home button, then enter task manager, the browser will still run. if you start the browser and press the back button and open the task manager, it will show that the browser is not running anymore (actually, the browser was a bad example, since after a little bit of browsing you'd have to push the back button quite a lot since its primary function is to go back). the same goes for many more apps, whatsapp, facebook, twitter, angry birds...
Pkplonker said:
I miss this from my oxygen rom'd desire
Click to expand...
Click to collapse
me too. adamG has apparently got a SGS2 though
Thinking about it, I would also like this functionality although it isn't so urgent for me. If more people show interest maybe I'll attempt it as my first android app For such a simple app my opinion is that it should be free and not packed with admob spam, but if another dev wants to attempt it that's their choice I guess.
My thoughts:
It should be quick to develop a simple app providing this functionality. Just have it bind to an event which fires when the back button is pressed long, and have it kill the app whichever is first in the foreground window Z-order (I'm fairly new to the Android API, so I use Win32 API terminology here for example only). The only complexity may be to make the event bound globally (in all apps), as opposed to only bound in the app itself - hopefully that doesn't require root! I guess it should be a background service which runs on boot, and perhaps a very simple gui app to control that service (in fact would there be anything to configure at all? What do you think?).
sl9 said:
Thinking about it, I would also like this functionality although it isn't so urgent for me. If more people show interest maybe I'll attempt it as my first android app For such a simple app my opinion is that it should be free and not packed with admob spam, but if another dev wants to attempt it that's their choice I guess.
My thoughts:
It should be quick to develop a simple app providing this functionality. Just have it bind to an event which fires when the back button is pressed long, and have it kill the app whichever is first in the foreground window Z-order (I'm fairly new to the Android API, so I use Win32 API terminology here for example only). The only complexity may be to make the event bound globally (in all apps), as opposed to only bound in the app itself - hopefully that doesn't require root! I guess it should be a background service which runs on boot, and perhaps a very simple gui app to control that service (in fact would there be anything to configure at all? What do you think?).
Click to expand...
Click to collapse
It would need to be in the framework of the rom, I think
Chef_Tony said:
well the back button does kill apps.
if you start, say, the browser and press the home button, then enter task manager, the browser will still run. if you start the browser and press the back button and open the task manager, it will show that the browser is not running anymore (actually, the browser was a bad example, since after a little bit of browsing you'd have to push the back button quite a lot since its primary function is to go back). the same goes for many more apps, whatsapp, facebook, twitter, angry birds...
Click to expand...
Click to collapse
Yeah it does, but you have to press and press and press...would be cool, if you can "hold down" the button for a sec and it will end the task.
Example...when i'm at handsentSMS > SMS > keyboard open...
Pressing BACK > close keyboard
Pressing BACK > closing SMS windows
Pressing BACK > closing handsentSMS
3 times pressing this button after every SMS suxx...sorry
Yeah i can press the HomeButton, but then its in my mind, that the app is running in background...isnt that bad at android-OS-structure, but its a bad feeling to me...
yes that's true. i was reading over your original post again and the first time through i must have overread the part where you named sms and the browser as examples. you are right, in that case, it does not work very well. an alternative way is to hold the home button, then press task manager and kill the app instantly. but that takes even longer. i guess your best option is to actually let it run in the background, if you want to get out of it fast.
pulser_g2 said:
It would need to be in the framework of the rom, I think
Click to expand...
Click to collapse
I suspected this may be the case, really hope it isn't but I understand the Android security model needs to enforce a certain level of isolation for each app in the VM I'll do some further reading of the documentation to find out for sure, since a simple non-root APK providing this functionality for users would be very welcome.
I'm too used to other less-secure API's (Win32) in which any app could basically do whatever it wanted to other apps and the OS; I guess thats why virus authors love Windows so much
yeah just for anyone not totally in the know, there is a difference in android between pressing the BACK button and HOME button to leave an app. using the back button to leave an app and go back to the home screen basically "kills" the app. it puts it in a state where it can readily be killed by the OS in an instant.
when just pressing HOME to leave an app, the app is technically backgrounded. the OS will keep it around longer or in a different fashion.
so backing out of apps with the back button is always the way to "exit" any app.

[Q] Save the lock button

Most of the problems caused is due to the frequent use of the lock unlock button, so I was thinking if we could if at all possible, not use the button!!
->The first thing is that if we could re-map the function of that button to some other button, like to the call button which is useless! We have the kind of remap in the Windows phone roms, something of that kind for the Android roms! Maybe!!
-> OR maybe create a script that runs so as to lock the screen as if the lock button was pressed! the code that actually runs when you press the lock button! a widget can be created to lock the screen and you can unlock it by just pressing any button!! This is just gonna require little programming!
This is just a thought that i came across, and my question to the Devs is that if at all any of this is possible, can we do it?? So as to save our almighty LEO!!
There are tonnes of apps and widgets that can do this already, just use one of those. I'm sure there's even a way to put it in the notification bar so that you have easy access anywhere within the OS.
Nigeldg said:
There are tonnes of apps and widgets that can do this already, just use one of those. I'm sure there's even a way to put it in the notification bar so that you have easy access anywhere within the OS.
Click to expand...
Click to collapse
Thanks for the reply.. Why are we waiting to have it in each of our roms then!! We must have it inbuilt in the rom so that all the button based problems are solved!
p.s can you name a few apps/widgets that you said can do the job??
I strongly disagree with that, there's no reason to have it built in into the ROM. I for one would never use it, because it's just so much easier to press the power button. Sure, it dies eventually, but by then most would have moved on to a new device. Having had this phone for two years now, I haven't had any issues with the power/lock button.
As for the apps and widgets, search on Google Play and find them yourself.

Mouse Right Click Behavior

Hi,
I bought this remote:
http://g03.s.alicdn.com/kf/HTB1clsdIXXXXXXlXVXXq6xXFXXXn/2-4GHz-Fly-Air-Mouse-Wireless-Keyboard.jpg
but I'm having trouble with the "back" key. It's not really acts as back. Instead it acts as right click.
Has anyone been able to fix this problem?
I xposed module would be nice
I did some research and found this:
https://github.com/timduru/platform-frameworks-base/commit/bae953c0063dc1afb9e8c43381f3894329abe115
Think this is exactly what we need to fix this.
Is it possible via xposed module? Maybe any Devs are interested in that one?
Use esc button for back key
ilkerates said:
Use esc button for back key
Click to expand...
Click to collapse
Yes, I'm sure he's already aware of that.
Speaking personally, it would be nice if my back button on my air mouse (the same one as the OP has which, despite being marked as a back button, is effectively seen by Android as a right mouse click) actually worked as a back button. To stop having to turn my air mouse over to access the esc key every time I wanted to go back, given that the QWERTY doesn't work when pointing downwards. I had to remap my Menu button as the back button isn't seen by any key mapping apps.
So yes, a big thumbs up from me too if this can happen in Xposed. I'm rooted and running it already.
Beefheart said:
Yes, I'm sure he's already aware of that.
Speaking personally, it would be nice if my back button on my air mouse (the same one as the OP has which, despite being marked as a back button, is effectively seen by Android as a right mouse click) actually worked as a back button. To stop having to turn my air mouse over to access the esc key every time I wanted to go back, given that the QWERTY doesn't work when pointing downwards. I had to remap my Menu button as the back button isn't seen by any key mapping apps.
So yes, a big thumbs up from me too if this can happen in Xposed. I'm rooted and running it already.
Click to expand...
Click to collapse
Yes this is what I am also trying to do, so if anyone has figured out how to make the right mouse button into the back button that would be amazing!!
Xposed Additions may work for you.
ErAzOr2k said:
I did some research and found this:
https://github.com/timduru/platform-frameworks-base/commit/bae953c0063dc1afb9e8c43381f3894329abe115
Think this is exactly what we need to fix this.
Is it possible via xposed module? Maybe any Devs are interested in that one?
Click to expand...
Click to collapse
what exactly is this? thanks
[email protected] said:
Yes this is what I am also trying to do, so if anyone has figured out how to make the right mouse button into the back button that would be amazing!!
Click to expand...
Click to collapse
It's impossible as far as I'm aware to map the back button on my air mouse to a specific activity. Like I said, I ended up mapping the menu button instead. I've gotten used to it now.
Mogster2K said:
Xposed Additions may work for you.
Click to expand...
Click to collapse
Unfortunately not. In fact, not only did it not work, it caused delay issues in button presses on my NVidia controller. This only stopped when it was deactivated within Xposed.
Only other thing I can think of would be to create a custom profile in /system/usr/keylayout/, however I don't know the details of how to do it.
Sent from my LG-H811 using Tapatalk
nice !
nice !
Any updates with this issue? I was actually coming here to post about a similar problem.
Just picked up my Shield TV and tried using this same remote. The center button (select button; left click button) doesn't function at all. I can scroll up and down, left and right, air mouse cursor works fine. But I can't actually make a selection.
I also find that with either the controller or nvidia remote, I can't navigate in app file structures. So when I side load ES Explorer for instance, I can't get into the center of the screen and navigate the file list, only the top and bottom border menus. Or when I sideloaded ShowBox and other similar apps, I can't navigate the movie lists, only the top or bottom menus.
At this point I'm starting to think I'm either better off taking this thing back and using my old droid tv box. OR flashing this thing to make it act like a droid tablet and lose all the added functionality that the shield uses to set itself apart.
So, I bought this remote from amazon:
https://www.amazon.com/dp/B00UYCLV8Y/ref=cm_sw_r_other_awd_CTeTwbRCVNCP1
Which is pretty awesome so far. Everything works except the back button of course. I've been digging and digging and unfortunately I don't think we can change the behavior as it just doesn't seem to be recognized as a typical key scancode. I'm confident of this because I made a custom key layout file for this device, and literally edited 999 key entries, ranging from "key 0" all the way up to "key 999". I gave every keycode the back button tag. What this essentially did was turn every single button on the remote into a back button (lol), and as you may expect, even STILL the back button on the remote only registered as a mouse click.
After searching, it seems the only way to bypass this would to be to change the behavior of the mouse button itself, which according to resources online, is hard coded into the kernel itself. You would have to actually know how to code and compile a new kernel for your media device.
http://stackoverflow.com/questions/...ped-to-work-for-traversing-back-in-jelly-bean
I have created a simple keylayout that anyone can use if interested. It's pretty much just a rip of the generic.kl file, with the zoom in and out buttons on the remote configured as back buttons. If you use a proper keycode scanner, you can study this keylayout file and eventually customize any button (except the back button of course) to do almost anything you want.
It's a temporary workaround until someone figures it out. If it doesn't work for you, you may need to change the filename to reflect the proper vid and pid of your device. I did this by plugging my device into windows and checking the hardware id for the new mouse and keyboard input that popped up.
I'm not sure which directory the file needs to be in, so I just copied it to both known directories:
Root: data>system>devices>keylayout
Root: system>usr>keylayout
I hope this helps.
Edit: Also, a couple of things to note, in case anyone was curious. If your having any issues trying to program the infrared side for a remote, consider that the source remote may be blasting too much for this remote to learn. I discovered this issue because my Samsung tv would send tons of ir data and causing my remote to have troubles learning. If you have a similar issue, try quickly/lightly tapping the button on the source remote when teaching this remote to learn it. Had no issues teaching my remote once I figured this out.
Finally, an oddity I noticed is that the issue seems specific to Android TV boxes. Connecting the USB to my galaxy note 5 via USB otg cable, the back button works fine on its own on this remote. Oddly though, while it registers as a key using the key test app (Google it), it reports back as having a scancode of 0.
Tried adding key 0 as a button in the keylayout config. Still no go. :/
I've made a custom kernel based on stock kernel to (hopefully) change the rightclick event to back event.
Is anyone brave enough to check this out as I don't give a guarantee to anything?!
ErAzOr2k said:
I've made a custom kernel based on stock kernel to (hopefully) change the rightclick event to back event.
Is anyone brave enough to check this out as I don't give a guarantee to anything?!
Click to expand...
Click to collapse
tried your boot.img, and as far as i can tell, nothing.
my shield tv is already unlocked and rooted, so i just used "fastboot flash boot boot.img" in adb to flash the boot image to my device. booted up fine, just i dont see any changes regarding right mouse click.... :/
has anyone figure this out yet. I really need to change the right click to function as "back"
Has anyone been able to fix this meanwhile? With Xposed Module maybe?
I'd love a Magisk (or Xposed) module that fixes that, but I don't think any module like that exists right now...
There are work-arounds to use apps that create fullscreen overlay which intercepts right clicks and emulates a Back button, but those don't work on Shield (or Android TV in general) because creating Overlay / requesting "draw over other apps" permission causes a crash
For now, the most convenient (more than editing *.kl files) work-around I've found is to use an app called Button Mapper (packagename: flar2.homebutton, can't post a link cause I'm a newbie) and emulate Back button on some other button...

Categories

Resources