0

I made a texting app for Android. When I tested it I found that if I try to go into silent mode (on a phone) the texting app will still go off, because it is set to a "media" and not a "ringtone" volume type.

Is there any way to change this so when I silence my phone, my app will also be silenced? I don't want the user to have to try and fix it.

Update: Sorry for any confusion. This has been a side project I did a while ago and I am just coming back to it now.

The project is a voice to text/ text to voice converter so all commands in the project can be done through voice. The app will "talk" to you through each step of the program. I want to have the ability so silence all "talking" that the app does to you the user if the phone is on silence. Here is how I handle voice feedback:

import android.speech.tts.TextToSpeech;

public class VoiceFeedback implements SMSFeedback{

  private TextToSpeech tts;
  private String text;

  public VoiceFeedback(TextToSpeech tts, String text){
     this.tts = tts;
     this.text = text;
  }

  public void play(){
    tts.speak(text, TextToSpeech.QUEUE_FLUSH, null);
  }
}

I guess the real question I should be asking is:

Is there a way to tell if the phone is silenced so that I can edit the code to not include voice feedback when there is?

Thanks!

Soatl
  • 10,224
  • 28
  • 95
  • 153
  • Can we see the code that plays the sound? – fredley Mar 10 '11 at 15:38
  • Yea I will add it once I get back to my laptop. There are a lot of voice commands that get sent back to the user (the whole app is a text-voice voice-text converter) so there is a lot of different pieces of code that are making these calls – Soatl Mar 10 '11 at 15:52

1 Answers1

0

You should be using a Ringtone object to play ringtones and alerts. You need to use RingtoneManager in order to obtain a Ringtone object, which has a method setStreamType() which you can use to play through the appropriate stream.

fredley
  • 32,953
  • 42
  • 145
  • 236