android-audiomanager

What triggers (or generates) KeyEvent.ACTION_MULTIPLE?

邮差的信 提交于 2019-12-03 11:07:13
The documentation for KeyEvent.ACTION_MULTIPLE says: "multiple duplicate key events have occurred in a row, or a complex string is being delivered. If the key code is not {#link KEYCODE_UNKNOWN then the {#link getRepeatCount() method returns the number of times the given key code should be executed. Otherwise, if the key code is KEYCODE_UNKNOWN, then this is a sequence of characters as returned by getCharacters()." But it doesn't say how to actually generate that event. I tried (rapidly) double-clicking the headset's Pause/Play button, but all I receive is ordinary ACTION_UP and ACTION_DOWN. I

Play audio file during a call, however the person on the other end is not able to hear it

心不动则不痛 提交于 2019-12-03 10:06:45
I want to play audio file during a call and i'm able to play it but when i make a call it play file only on that device on which i have installed the application. here is my sample code by which i have played the audio file. public void play() { bufferSize = AudioTrack.getMinBufferSize(16000, AudioFormat.CHANNEL_CONFIGURATION_MONO, AudioFormat.ENCODING_PCM_16BIT); AudioTrack at = null; at = new AudioTrack(AudioManager.STREAM_VOICE_CALL, 16000, AudioFormat.CHANNEL_CONFIGURATION_MONO, AudioFormat.ENCODING_PCM_16BIT, bufferSize, AudioTrack.MODE_STREAM); String filePath = Environment

How to turn on speaker for incoming call programmatically in Android L?

Deadly 提交于 2019-12-03 09:45:39
I want to accept an incoming call using answering phone's GUI (Phone's GUI) of my phone in Android 5.0. I found a way that needs to make an activity which use to send some action to open the Phone's GUI. I was successful to turn on the Phone's GUI for an incoming call. The issue is how can I turn on the speaker for the Phone's GUI. I tried the code but it does not turn on. Could you help me to solve that issue in Android L audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); audioManager.setMode(AudioManager.MODE_IN_CALL); if (!audioManager.isSpeakerphoneOn()) audioManager

Get info about audio, playing in another application

时光毁灭记忆、已成空白 提交于 2019-12-03 09:12:31
How can i get info about source (filedesc. or uri) from which another application playing audio? In AudioManager there is only isMusicActive() method, which doesn't give any additional information. And because of it isn't my application, i doesn't have any MediaPlayer object. Juan Cortés Register a broadcast receiver for known action intents and handle the broadcast to show or do something with the track information, source : public class CurrentMusicTrackInfoActivity extends Activity { public static final String SERVICECMD = "com.android.music.musicservicecommand"; @Override public void

How to provide customized vibration on specific incoming calls

若如初见. 提交于 2019-12-03 01:25:45
The program functions like this: the user has a list of phone numbers, for which the cellphone could vibrate upon an incoming call only when no other system-wide application would provide vibration (such as in mute mode). I know that this is somehow against the rules, for that an application should respect the users' settings, but the application is limited to some certain users with this need. I have tried two ways but neither of them are satisfying: Listen to the telephony state and directly trigger the vibration service with my own pattern (with Vibrator.vibrate() ). This method is

How to play or resume music of another music player from my code

為{幸葍}努か 提交于 2019-12-02 16:51:31
In my Android app I want to play or resume the played music after I pause it. I got my app to pause the music by sending a broadcast , but I can't get it to play or resume the music. Here is the code to pause: Intent i = new Intent("com.android.music.musicservicecommand"); i.putExtra("command", "pause"); sendBroadcast(i); Here is what I have discovered after testing these. I have tried and verified these commands to work just fine. // pause Intent i = new Intent("com.android.music.musicservicecommand"); i.putExtra("command", "pause"); sendBroadcast(i); // play Intent i = new Intent("com

Check if Android mic is being used by another app

大兔子大兔子 提交于 2019-12-02 08:35:31
问题 I want to check the noise level using the android mic. However before accessing the mic I want to know if the mic is being accessed by another application. How do I check if the mic is being accessed by another application? 回答1: Information about active input streams and where they are routed is held by the AudioFlinger , AudioPolicyManager and AudioHardware instances, which do not share this information with applications. The AudioManager class provides an isMicrophoneMute() method to

Why does ACTION_MEDIA_BUTTON fail to process events?

混江龙づ霸主 提交于 2019-12-02 07:20:39
问题 Following the training section on how to use hardware playback control keys to control audio playback, I create a listener class: public class RemoteControlReceiver extends BroadcastReceiver { @Override public void onReceive(Context arg0, Intent intent) { if (Intent.ACTION_MEDIA_BUTTON.equals(intent.getAction())) { KeyEvent event = (KeyEvent)intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT); Log.e(TAG, "ACTION_MEDIA_BUTTON"); int keycode = event.getKeyCode(); switch (keycode) { case KeyEvent

Why does ACTION_MEDIA_BUTTON fail to process events?

为君一笑 提交于 2019-12-02 03:21:29
Following the training section on how to use hardware playback control keys to control audio playback , I create a listener class: public class RemoteControlReceiver extends BroadcastReceiver { @Override public void onReceive(Context arg0, Intent intent) { if (Intent.ACTION_MEDIA_BUTTON.equals(intent.getAction())) { KeyEvent event = (KeyEvent)intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT); Log.e(TAG, "ACTION_MEDIA_BUTTON"); int keycode = event.getKeyCode(); switch (keycode) { case KeyEvent.KEYCODE_MEDIA_NEXT: Log.e(TAG, "KEYCODE_MEDIA_NEXT"); break; case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:

How to check and redirect audio between wired headset and speaker phone?

北城余情 提交于 2019-12-02 02:22:48
I am developing a simple app , that should toggle between speaker phone and wired headset to play audio on a button click event. I am trying to make use of isWiredHeadsetOn() function, but it says that this is deprecated for Android API lvl 5 onwards. So how do I check if currently audio is playing or not through wired headset so that I can redirect it to the phone speaker? Note: I start my app with the headphone plugged to the 3.5mm jack of the phone. This is my attempt at the code so far: protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView