Android App execute code on unknown button click - android

I am working on an android app to run as a front end on my Parrot Asteroid Smart which runs a modified version of gingerbread as my cars headunit.
At present the unit natively senses the reverse gear signal and displays a "complete action using" dialog which displays one of two camera applications.
I don't have a camera but what I want to do when it senses reverse is to reduce the volume to a set value. I have completed the code to do volume adjustment, however.
I am having an issue determining what button input or trigger the reverse gear is producing. I have already tried some code which logs the onKeyDown event which I have confirmed works when I click the menu or back button but when I trigger the reverse signal there is no log for a keydown.
Although I have a number of years experience in other languages I am new to android app development and java so no suggestion is to ridiculous at this time.

It seems to me like the reverse gear is triggering an Intent since it displays the app chooser dialog. It is probably sending a MediaStore.ACTION_IMAGE_CAPTURE intent or something similar that will require a camera app to complete. If that is the case, then you could modify your app and register to receive those intents and handle them however you'd like.

Related

How to stop speech recognition with a button on Android?

I currently use RecognizerIntent to perform STT on an Android app. When a user clicks a button, the Google Voice Input screen pops up, the user can speak and it is transcribed. When it is quiet enough, the popup shuts and the input is processed.
However, the popup will not shut / process the results if there is still some background noise (despite having transcribed the necessary words).
If I click the screen, the popup disappears, but the results are not processed.
Is there a way to click the popup window (the microphone that pops up) to force the app to stop recording and process the results it has already transcribed?
Thank you in advance!
Your question is not about the Android OS but about a particular end-user app that implements the RecognizerIntent activity.
Google app v10.98.7.21 on Android v10 does not seem to have this feature that you're after. However, there is no way of knowing for sure because it's a closed source app, without detailed release notes nor end user documentation, nor does it make any commitments regarding its future behavior. A good idea for your app is not to depend on such 3rd party apps.

Is it possible to dial numbers programatically on the dialer while on an active call..?

I have been recently working on an app which requires to respond to an Automatic attendant (virtual receptionist) which allows callers to be automatically transferred to an extension without the intervention of an operator/receptionist.
My requirement is such that to make a scheduled phone call to a particular number and to respond to the Automatic attendant instructions ("for sales, press 1, for service, press 2," etc)
Is it possible to achieve similar action that i could otherwise achieve by responding to the system manually by pressing an option (say 1 or 2 from above example) programmatically while the call is still active.
Any help is appreciated.
There's no way to do this. There isn't an API, and since the dialer is not part of the OS and can be any app, you can't count on anything working on all devices.
The best chance you have is to assume the dialer will accept USSD input (USSD is an ancient telephony protocol for sending data to phones). In the USSD language, a comma is a pause. SO if you want to dial a number, than 1 at the prompt you could ask it to dial "number,,,,1" and hope that the dialer accepts USSD input and that the pause is long enough to dial the 1 at the right time. But it will work on only a subset of all devices, and be fragile there.

Android Soft Button and Hardware Button

I want to create an app that is not usable by the user but performs some functionality outside the app, the app just run in the foreground and listen to the press of android hardware/software buttons, the likes of Power button, home button, volume up and down. It triggers a call when for instance, the volume up button is pressed down for 5 secs and notification appears.
I have checked solutions like this
Intercepting the back button
How to override the behavior of the volume buttons in an Android application?
But this solutions have something to do with the user accessing the app directly, i mean to perform this functionalities you have to be on the app which i don't want.
The app was suppose to be run on a smart watch which runs android OS. I was thinking if i can perform this on android phone, it should be easier on the smart watch.
Note:
The App is for targeted users, who will be trained to understand that behavior.

Can we automate "Call Receiving" feature in android?

I'm trying to automate calling features in android using robot framework + appiumLibrary.
What I've done so far?
I am able to dial a number using these steps :
Step 1.
Open Application http://localhost:4723/wd/hub platformName=Android platformVersion=5.0.1 deviceName=4a119f6b appPackage=com.android.contacts appActivity=com.android.contacts.DialtactsContactsEntryActivity
Step 2. AppiumLibrary.Click Element name=Keypad
After this I clicked on each number one by one and then clicked on dial button.
Where am I stuck?
In similar fashion I am trying to automate Call receiving feature. I'm dialing from some other phone on connected device and while phone is ringing I'm trying to capture screenshot of xml using uiautomatorviewer.
It is not capturing it.
Is it the right approach?? Is there any other way to automate this functionality?
This depends on your screen mode when you receive it:
If the screen is asleep, i.e., when a call is received it opens the activity to deal with the call, then you can detect what is the package on the screen and match it with the package of the call activity.
If the screen is awake, i.e., when a call is received you see like a small pop up on the top of the screen with the "Answer/Reject" options, then UiAutomatorViewer can't detect them. I don't know if Appium can detect it or not, but I suppose it can't (UiAutomator can't for instance, it can only detect what UiAutomatorViewer detects).
In summary, if a new app is opened, you can detect it is the call app. Otherwise, the "popup" isn't detectable.

Creating 'middleman' headset button controller in Android

All,
I have searched for an answer to this, but I'm not getting anything exact... It's my first time writing an Android app, so please be gentle :)
I'm pretty bummed about the minimal headset support in Android - unlike e.g. iPhone, it only natively seems to support a single button, so no volume control on headset compatibility. Additionally, if I'm listening to music and a call comes in, the OS pauses the music automatically, but the headset button still functions ONLY as a media button - I can't use it to answer/end the call. If I answer the call via the screen and press the headset button, the music starts again, but the call continues...
I'd like to create a 'middleman' app that can pick up that the headset button has been pressed (via Keyevent.KEYCODE_HEADSETHOOK) and can then determine whether to perform the default ACTION_MEDIA_BUTTON action (toggle play/pause in my chosen media player) or, if there is an incoming call, pause the music and answer the phone (and then, when pressed again, end the call and restart the media player). Perhaps even check for ACTION_MULTIPLE on the headset button to assign different options (ACTION_MEDIA_NEXT, ACTION_MEDIA_PREVIOUS etc.). Perhaps also be able to determine whether different buttons on the headset have been pressed (if the headset is e.g. a fancy iPhone headset) and 'translate' those button presses into the appropriate ACTION_MEDIA_*). This might not be possible if the OS can't tell the difference between different buttons, obviously.
Obviously such an app would have to receive the intent with a high enough priority that it would be able to abort the broadcast before the current media player gets it.
I've been tinkering with creating assorted BroadcastReceiver classes and intent filters etc., but part of the problem is that the bult-in Android emulator that comes with Eclipse doesn't seem to have the ability to simulate a user plugging in the headset and/or subsequently clicking the headset button. Therefore, every time I get somethign that looks promising, I have to put it onto my actual phone and try it out - time-consuming and a hassle.
3 questions then:
Am I missing somethign obvious - is this a real problem and if so, has it already been solved?
If it IS a problem, is it possible to write such a middleman app?
Are there any other Android emulators that can check for headset-related activities?
Thanks,
Rory
i´ve already written exactly this kind of app. Its called like the topic of this thead: Headset Button Controller ;-)
http://www.androidpit.com/en/android/market/apps/app/com.kober.headset/Headset-Button-Controller
Cheers Christoph

Categories

Resources