Discover android headset controls, include the articles, news, trends, analysis and practical advice about android headset controls on alibabacloud.com
Android headset line control details, Bluetooth headset button monitoring (similar to cool dog line control effect)
When the media button of the headset is clicked, the Android system sends a broadcast. The broadcast carries an Intent with the Action MEDIA_BUTTON. After lis
Customer requirements
After the headset is pulled out during FM playback, The FM app displays a prompt box Indicating "unplug the headset and stop the FM", and then automatically close
Modify fmradioservice. Java1. Add the following import to display the toast
/// AAAAA add start
Import Android. widget. Toast;
/// AAAAA add endpublic class fmradioservice extends
After the customer asks the FM to unplug the headset during playback, the fm app displays a prompt box Indicating "unplug the headset and stop the Fm", and then automatically closes
Modify FMRadioService. java1. Add the following import to display the toast/// AAAAA add startImport android. widget. Toast;/// AAAAA add endPublic class FMRadioService extends Servic
Bluetooth headset, the screen of your phone to increase or decrease the volume, then the key value is transferred from the Bluetooth headset. Conversely, if the internal volume of the Bluetooth headset is changed, Android has no response whatsoever, Then it is the function that co
Example of headset plugging and audio channel switching for Android underlying development
Example of headset plugging and audio channel switching for Android underlying development
Because the headset is separated by the headset
The example in this article describes the Android implementation method for adding headphones status icons. Share to everyone for your reference. Specifically as follows:
The original eco-Android system is not indicated by a headset insert or insert status, this article explains how to add a headset insert status indi
-> state_on;
Switch_data_headset-> state_off = pdata_headset-> state_off;
Switch_data_headset-> SDEV. print_state = switch_headset_print_state;
Info-> psw_data_headset = switch_data_headset;
Ret = switch_dev_register ( switch_data_headset-> SDEV );
In the/sys/class/switch directory, the h2w sub-directory will be generated, with some members such as State and name, and the driver will determine whether the headset is inserted through
Gpio simulates the
AudioManager has the following method:
IsWiredHeadsetOn ();
If the headset is inserted, true is returned; otherwise, false is returned;
Of course, you must add a permission. Otherwise, false is always returned.
I started to catch up with the source code for a long time. I found the process of real-time detecting the insertion and removal of headphones, but it is not very helpful for me.
Real-time Monitoring of hea
AudioManager has the following method:IsWiredHeadsetOn ();If the headset is inserted, true is returned; otherwise, false is returned;Of course, you must add a permission. Otherwise, false is always returned.I started to catch up with the source code for a long time. I found the process of real-time detecting the insertion and removal of headphones, but it is not very helpful for me.Real-time Monitoring of headset
are possible key codes that print out the user pressed key//if (Keyevent.keycode_media_next = = keycode) {//sb.app End ("keycode_medIa_next ");//}//Note: When we press the Media_button middle button, the actual departure is keycode_headsethook instead of//Keycode_media_play_pauseif ( Keyevent.keycode_media_play_pause = = keycode) {//sb.append ("Keycode_media_play_pause");} if (Keyevent.keycode_headsethook = = keycode) {//sb.append ("Keycode_headsethook");} if (keyevent.keycode_media_previous =
AndroidIn fact, the code of the headset detection is rarely changed.
This is because there are few documents.
It took nearly two months.
The driver has three implementation versions:
First, drivers/Char/micco_hsdetect.cIt reports the status to the user space through kobject_uevent.
Second: Drivers/input/keyboard/micco_keys.cIt reports events to the user space through input_report_switch.
Third: Drivers/switch/switch_micco.cRegistered a switch_dev, whi
Android automatically exits the FM Radio application when the flight mode is enabled and the headset is pulled out.
The FM radio needs to be inserted into the headset as an antenna, and automatically exits when the headset is pulled out.
1. First add the prompt string
Mediatek/packages/apps/FMRadio/res/values/strings.
PrincipleIn fact, the Android system will send the broadcast when the headset is plugged in and unplugged, so we want to detect the headset's status only needs to register the response of the broadcastreceiver, the status of the response to the judgment is OK.The name of the broadcast is called:Android.intent.action.HEADSET_PLUGCode Packagecom.yydcdut.ear;ImportAndroid.os.Bundle;Importandroid.app.Activity;I
PrincipleIn fact, the Android system will send the broadcast when the headset is plugged in and unplugged, so we want to detect the headset's status only needs to register the response of the broadcastreceiver, the status of the response to the judgment is OK.The name of the broadcast is called:Android.intent.action.HEADSET_PLUGCodePackage Com.yydcdut.ear;import Android.os.bundle;import Android.app.activity
Audiomanager has this method:
Iswiredheadseton ();
Returns true if the headset is inserted, otherwise false;
Of course, to add a permission, or always return false.
I started chasing after a long time source code. The process of detecting headphone inserts and unplugging was found in real time, but not very helpful to my needs.
Real-time detection of headphone insertion and pull-out:
Every time you insert and unplug headphones, the system sends intent
Android cainiao study note 13 ---- Android controls (2) simple examples of custom controls, android Custom Controls
Sometimes, you may feel that the control provided by the system is too ugly, and you need to customize the control
Android _ android binds events to button controls in five ways. Android button controls
I. Preface
Here, we will introduceBinding events to controls -- buttons in Android.
II. Specific
Android 7 (creating custom controls) and android controls
I learned how to use the basic controls and layout of android, but the basic controls and layout sometimes cannot implement com
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.