android-audiomanager

Android: What Audio Mode should be set to send receive voice between devices

岁酱吖の 提交于 2019-11-28 04:03:28
问题 I am trying to stream voice/audio (two way) between two Android devices Tablet and Mobile (over java sockets). The Tablet can play received audio(voice) clearly, but the Mobile plays received audio as noise. Then i set this audio mode in the code on tablet: audioManager.setMode(AudioManager.MODE_IN_CALL); This now results in Mobile receiving clear voice. But the tablet goes silent, it does not play the received audio (or rather its not audible). I am not sure what combination (if any) of

Set media left/right volume separately?

我的未来我决定 提交于 2019-11-28 02:14:29
I would like to override the media left and right volume setting separately as a whole. It does not seem possible to set the left and right volume separately using AudioManager.setStreamVolume() . I noticed it is possible though to set it with MediaPlayer.setVolume() or SoundPool.play() but I would like to override the whole system media settings so the stereo balance would be kept among the different music players and applications. I'm not really familiar with Android so I would welcome all advices, tips that could help me achieve this. ps: I am working on Android 2.3.4. and I would not mind

Playing sound over speakers while playing music through headphones

旧时模样 提交于 2019-11-27 23:17:14
I have an AudioTrack streaming via headphones. I have to send a SoundPool to built-in speakers only, without interrupting the AudioTrack playing over the headphones. Any hacks gangsters? Michael Many Android devices use a single output thread in the AudioFlinger / audio HAL for all local playback (earpiece, speaker, wired headset/headphones), making different routing of two tracks simultaneously impossible (which is why on many devices the media streams are forcibly muted if a notification is played and you've got a wired headset attached; because otherwise you'd hear the music in the

Android: Voice Recording and saving audio

三世轮回 提交于 2019-11-27 22:23:57
I am working on application that will record the voice of the user and save the file on the SD card and then allow the user to listen to the audio again. I am able to allow the user to record his voice using the RecognizerIntent, but I cant figure out how to save the audio file and allow the user to hear the audio. I would appreciate it if someone could help me out. I have displayed my code below: // Setting up the onClickListener for Audio Button attachVoice = (Button) findViewById(R.id.AttachVoice_questionandanswer); attachVoice.setOnClickListener(new OnClickListener() { public void onClick

Android - can I mute currently playing audio applications?

孤人 提交于 2019-11-27 19:11:27
Hi I'm new to this. My self-teaching project is a small application which plays an audio news stream. To be effective, the application really needs to interrupt any currently playing media players (eg: Last FM, Imeem, music player, Spotify etc). I don't know what will be playing or what application will be playing it, but I want to ask them all to pause until I've done. Sounds rather bold, I know, but it must be possible, because when there's an incoming call, that's basically what happens. Can I send a message to all audio players asking them to pause for a moment? Could I spoof an incoming

Constantly check for volume change in Android services

旧街凉风 提交于 2019-11-27 18:15:57
问题 I wrote this piece of code, it's obviously flawed. How do I go about creating a service which will constantly check for changes in volume? Key listeners cannot be used in services, please don't post an answer with volume key listeners. My code is wrong because I've given dummy condition for the while loop. What has to be the condition for my service to check for volume change and not crash? It can't be isScreenOn() because volume can be changed while listening to music and the screen is off.

How to mute audio in headset but let it play on speaker programmatically?

孤者浪人 提交于 2019-11-27 15:21:47
I am searching a work-around for my problem specified in this question: How to disable the wired headset programmatically in Java As mentioned there, I am getting audio in both my speakers and headphones. Can someone please tell me how to mute the audio in the headset programmatically , while letting it play undiminished on speaker? AudioManager am = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE); am.setMode(AudioManager.MODE_IN_CALL); am.setSpeakerphoneOn(true); And then play the sound through the AudioManager.STREAM_SYSTEM stream. When the sound's finished playing be sure to

Android: How to generate a frequency?

时间秒杀一切 提交于 2019-11-27 14:05:34
Is there a nice way in Android to generate and then play a frequency (eg. 1000hz, 245hz)? Take a look at android.media. ToneGenerator . You can also try following Code. public class PlaySound extends Activity { // originally from http://marblemice.blogspot.com/2010/04/generate-and-play-tone-in-android.html // and modified by Steve Pomeroy <steve@staticfree.info> private final int duration = 3; // seconds private final int sampleRate = 8000; private final int numSamples = duration * sampleRate; private final double sample[] = new double[numSamples]; private final double freqOfTone = 440; // hz

Android : Calling Activity from Fragment

爱⌒轻易说出口 提交于 2019-11-27 12:30:58
I am using fragments inside an activity. I am using MediaRecorder to for audio recording. I have two part of an activity. 1st itself the Activity which will list the recorded file. On it's right side the AudioRecording Activity is called when one select to record for a new file. When the any of the listed file is selected i am using AudioPlayer as to play the recorded file. I am here able to convert the Activity into fragment but when i press on Stop it is terminating the application. Please anyone can answer. My audiorecorder is working fine when i use it as simple activity. Any solution like

Ringer mode change listener Broadcast receiver?

自古美人都是妖i 提交于 2019-11-27 12:29:19
AudioManager am = (AudioManager)getSystemService(Context.AUDIO_SERVICE); switch (am.getRingerMode()) { case AudioManager.RINGER_MODE_SILENT: Log.i("MyApp","Silent mode"); break; case AudioManager.RINGER_MODE_VIBRATE: Log.i("MyApp","Vibrate mode"); break; case AudioManager.RINGER_MODE_NORMAL: Log.i("MyApp","Normal mode"); break; } From the code above I can get the ringer mode. What I would liek to do is listen the ringer mode changes and call a function. What I have been told is that I can register the AudioManager. RINGER_MODE_CHANGED_ACTION and listen the change intent in broadcastreceiver