ANDROID: Getting HW Key to trigger Event in Service - General Questions and Answers

I am starting an Android app (on my Galaxy Note 2). It is Rooted.
While the screen is off (or on) i want to be able to double tap a hardware key (ie. Power Button) and this triggers an event within my foreground / background service. If the screen is off, i want the screen to remain off. This is a development project so i require source code to make this happen. I will have root access so if i must programmatically modify standard items on an Android device then so be it.
Can you please recommend articles to help me compose all of the above. The best i've found so far is to replace the default Home Launcher with my own then time it for a double press otherwise launch the default home launcher. I'm still reviewing its limitations.
Thanks

Related

Need simple app HOME takes to home, RecentApps, Screen Wake by shake or screen touch

Need simple 3 different apps..
HOME
RECENT APPS
Screen Wake by shake / multitouch screen & allow to unlock unlock
Objective is not to use physical button as I've bad experience of using button they fail quickly due to mechanical wear, journey started with Nexus One...
Simple app HOME takes to home want to put in quick launch JKay, Screen Wake by shake or screen touch
Currently I use home launcher and select home required. May be someone can use this code & recode.
Also want to put the recentapps application to my quicklaunch.
I thinks its one liner code, can someone please make it available in Market, I'm sure it will go superhit...

[Q][Huawei U8150] End button behavior

Hi all, I want to try Cyanogenmod 7 (latest nightly of course), but I realized that the end button (red end call button) behavior is different from the stock rom. The stock rom behavior is:
if not in home screen -> go to home screen
if in home screen -> do nothing
if locked and screen turned on -> turn screen off
everything else -> do nothing
Notice that pressing the end button seems to be different than pressing the home button: if the current foreground activity does not respond, home button won't work (ANR window will show up); end button, instead, will simply go to home screen, like if it's killing the current activity. However, relaunching the closed activity restores its previous state (like when I use the home button to get away from an activity).
Cyanogenmod has stock gingerbread behavior (which should be fine, I know it's the android way), but I really would like to preserve my habits.
I already tried:
Spare parts: does not have the option I'd like
Remapping keys via keymaps: doesn't work since behavior cannot be defined using the available built-in commands
I'll get my hands dirty in the Android code if necessary (I'm a developer), but I really want to know if there is another way before looking at the source code.

[APP][WIP][DEVS NEEDED] Hands Free Now [ALPHA]

HANDS FREE NOW​
Hands Free Now is an attempt to fix the bug in Google Now that Google itself never fixed.
As most of you know, as of Android 4.1+, our headsets are configured to work as follows:
1. Single press for play/pause
2. Double press for next
3. Long press for Google Now
However, the long press option does not work when the screen is off. It works only when screen is on. This is a bizarre lack of feature because if the screen is on and unlocked, you might as well click the mic on the desktop widget to launch Google Now. Why would you need the long press option anyway?!
Several attempts were made by many people to bring Googler's attention to this lack of feature, but all of em were conveniently turned down.
So I guess it's up to us to fix it.
I have started making this app but being the newbie that I am, I'm not sure if I can finish it alone. That's why I request you guys to help me out with this.
Uploaded below is the first apk
Concept in brief:
1. Launch Audio service that intercepts media KeyEvents
2. Once KeyEvents are triggered, create an empty StandOut window that blocks the entire display.
3. Wake up device, disable keyguard and launch Google Now
4. Release wakelock immediately. and reenable keyguard
5. Kill process in 10 seconds
Steps to use:
1. Install app
2. Open app from launcher once. You can go back to Home after this if you want
3. Lock screen.
4. Jack in the head set and triple press the button.
5. Device should unlock itself and in some time will launch Google Now
6. Fire your voice command and wait for response.
7. In 10 seconds, the screen will lock again.
8. For these 10 seconds, your phone will not respond to touches (this is intentional and by design, because you would not want your phone to "pocket dial" while travelling)
Release Notes:
1. App is currently incompatible with music players
2. Battery effectiveness is unknown; you might have to uninstall it once you have tested it
If you can help, the source code can be found on GitHub.
Installed app, but it wont launch after 3 presses of the button, I get a double beep sound when doing so.
I can help out with testing if you want but as far as coding goes im not very useful xD
Bluetooth too?
Will it work with Bluetooth headsets as well or only wired ones?
THANK YOU!
I registered just to say thank you, your little app allowed me to have the kind of music control I alway longed for since i passed from iPhone to Nexus 5. I'm truly grateful.:good:
I had the problem when the screen was off. After when I long press the little button on my headset. Then comes a black screen with a message: please wait (initializing) but nothing does.
But this app solve my problem!
Now I can use Google Now over my Headset.
Thank you very much! ?
Seems an old thread, but nevertheless: Thank you! Finally it works!
I'm just curious if it would be possible to change add long-press functionality. The app AutoVoice is capable of receiving a long press (also with locked screen). But it doesn't help because it relies on the not working Google Search.
Possible idea: your App could register as a service capable of receiving the VOICE_SEARCH_HANDS_FREE intent, it could receive the long press and start its procedure. It won't work immediately because Android will display the "Choose default app" prompt, that obviously doesn't work when the screen is locked/off. In order to choose the default app one has to wake the screen and manually override the keyguard/lock (for example via Secure Settings Plugin and Tasker). The override is somewhat buggy, and even though the screen is on, the phone still 'thinks' it's locked. Now: long-press to receive the command for long-press while locked, see menu and select default app. ..Hope my explanation isn't too bad.
I'm investigation another workaround to get it working with music player.
Best regards, Grtschnk

How to set physical button to run app in android custom rom

I've got new mobile from ebay, Blackview bv6000, which has 3 special physical buttons
1. Camera
2. Sos
3. Ptt
Then i need to assign those buttons to run my app and some functions
I got stock rom from Blackview forum, after i extract system.img file and found
\usr\keylayout\Generic.kl
which contains list of key function that i need
key 212 CAMERA
...
#[AGOLD][2015.04.08]Fengjun merge
key 249 FUNC1
key 250 FUNC2
#[AGOLD]End
The question is how can i assign that key to run my app or function in my app when I'm in home screen or in other app or even the screen is off
You could try if "Xposed Additions" meets your needs. It allows you to set various general actions, though not opening a specific app.
(For Xposed to actually work, I needed Grorkmod on the bv6000)
I've managed to set PTT to turn on/off flashlight with it. However, this seems not to work for the condition "screen off" for whatever reason. As a workaround for "the screen off" condition I've set the click action to "Power", so the light turns on with a double click from "screen off".
If this is a good idea at all, time will tell. If this button is executed accidentally with the phone in a pocket, it will drain the battery fast.
EDIT: Apparently, the PRO version allows to execute apps.
"Physical Button Music Control", also based on xposed framework is free, can launch apps and do a lot more than the free version of "Xposed Additions", e.g. key combinations. I just gave it a try. However, it is still beta and a bit more complex to set up.

[APP][4.0+] iStart - one touch to start any app from anywhere

Hi everyone,
Do you want a start menu to start apps conveniently from any screen of Android phone ?
Please try iStart:
With iStart, there is no need to navigate back to home screen any more. iStart saves you a lot of taps and swipes each day
You can begin by using iStart's app organizer to set apps into groups, then launch any of them easily from a start menu panel that appears upon touching a start handle icon.
One-touch mode is absolutely convenient : keep your finger touched and swipe to the desired function on the panel, when releasing the finger the desired app will launch, or the desired action will be performed. Your thumb is now as powerful as a real mouse pointer !
The start handle can be positioned anywhere on screen that you want. If it is located near an edge it will be docked along that edge as a thin styled bar for easy swiping out.
MAIN FUNCTION
iStart works like a start Menu, with app groups being shown in customizable tabs.
Besides categorizing applications, you may also create shortcuts to any file or folder on your device and put them onto iStart for easy launching.
You may also create url links and put onto iStart for quick access: web url, sms compose url with ready-filled recipients, phone call url to any phone number, email compose url with ready-filled recipients. With these links on iStart, all your frequent actions or most favourite contacts are just one touch away.
System command actions are also made for your convenient use: turn-off screen, screen orientation setting, turning flashlight on and off, launch calculator app, launch calendar app, open system setting panel, start google assistant (Android L+), pull down notification bar, take a screen shot (Android M+), launch camera app, adjust media volume and ring volume, go back, go home, open recent applications screen.
PERMISSIONS
For functional purposes of iStart, following permissions may be requested at appropriate circumstances:
- Appear on top: iStart must be granted with this permission to show the start handle and the iStart panel. This is essential for iStart to work
- Storage access: in case you want to post your screen shots onto Gallery, you should allow this. This also enhances file shortcut creation function because you can then access more places on your storage when creating file shortcuts
- Do not disturb mode: in case you want to adjust ring volume to low level
- iStart accessibility service: this should be turned on for following things: pull down notification bar, navigating back (for use with a browser), open recent apps screen
- Device Administrator: in case you want to lock the screen with admin lock function. Note that this permission need to be turned off before force stop or uninstall iStart, unless you use the uninstall button of iStart itself.
- Make phone calls: this is used when you want to make a phone call from a iStart phone call link.
- Access phone book: in case you want to add people from phone book into phone call link or sms compose link
- Camera : this is to activate flashlight in old android devices
- Start at boot time: this is to auto start iStart when your device is restarted
Enjoy iSTART - one touch to start any app from anywhere. It's a simpler and more efficient way to use your phone
Dev
Invisible feature
Invisible feature: if you briefly touch the start handle it will act as a Home button for you.
Thank you for using iStart !

Categories

Resources