Check this out :
http://www.codeproject.com/Tips/462145/Handling-Phone-Events-in-Android-Programs

Does it help?


On 10 August 2013 22:07, shiva pendem <[email protected]> wrote:

> Hi,
> i have been debugging from past 3 days but unable to fine out the reason,
>
> As you have said i have added lot many permissions to make it run but it
> is not working fine,
>
> <uses-permission android:name="android.permission.READ_PHONE_STATE" />
> <uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS"
> />
> <uses-permission android:name="android.permission.READ_CONTACTS" />
> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
> />
> <uses-permission android:name="android.permission.WRITE_SETTINGS"
> ></uses-permission>
>       <uses-permission
> android:name="android.permission.CHANGE_CONFIGURATION" ></uses-permission>
>       <uses-permission
> android:name="android.permission.MODIFY_AUDIO_SETTINGS" ></uses-permission>
>
> these are the permissions added, and i am using, my phone samsung gt s6012
> model mobile phone,
>
> when i get a call i am not getting any voice from this speech and and no
> exception is also thrown for not getting the voice,
>
> Thanks
> Shiva Shankar
>
> On Sunday, August 11, 2013 1:58:36 AM UTC+5:30, shiva pendem wrote:
>>
>> HI every one,
>>
>> i would like to start a text to speech on a incoming call and i have
>> tried the following method,
>> private class CallStateListener extends PhoneStateListener implements
>> TextToSpeech.OnInitListener{
>>  public TextToSpeech tts;
>>  @Override
>> public void onCallStateChanged(int state, String incomingNumber) {
>> boolean entered=false;
>>                         tts = new TextToSpeech(ctx, new
>> TextToSpeech.OnInitListener() {
>> public void onInit(int status) {
>> // TODO Auto-generated method stub
>> if (status == TextToSpeech.SUCCESS) {
>> int result = tts.setLanguage(Locale.US);
>> if (result == TextToSpeech.LANG_MISSING_**DATA|| result ==
>> TextToSpeech.LANG_NOT_**SUPPORTED) {
>> Log.e("TTS", "Language is not supported");
>> } else {
>> speakOut("Test");
>> }
>> } else {
>> Log.e("TTS", "Initilization Failed");
>> }
>> }
>> });
>> switch (state) {
>> case TelephonyManager.CALL_STATE_**RINGING:
>> // called when someone is ringing to this phone
>> String text="";
>> if(!entered)
>> {
>> Log.v("Test","incomingNumber is "+incomingNumber);
>>  tts.speak("Hello "+getUserName()+" you have a call ",
>> TextToSpeech.QUEUE_FLUSH, null);
>> entered=!entered;
>> }
>> Toast.makeText(ctx,"Incoming: "+incomingNumber+"
>>  "+text,Toast.LENGTH_LONG).**show();
>> break;
>> case TelephonyManager.CALL_STATE_**OFFHOOK:
>> if(entered)
>> {
>> entered=!entered;
>> }
>> break;
>> }
>> }
>> public void onInit(int status) {
>> // TODO Auto-generated method stub
>> if (status == TextToSpeech.SUCCESS) {
>>
>> int result = tts.setLanguage(Locale.US);
>>
>> if (result == TextToSpeech.LANG_MISSING_DATA
>> || result == TextToSpeech.LANG_NOT_**SUPPORTED) {
>> Log.e("TTS", "Language is not supported");
>> } else {
>> speakOut("Test");
>> }
>>
>> } else {
>> Log.e("TTS", "Initilization Failed");
>> }
>> }
>> private void speakOut(String text) {
>> tts.speak(text, TextToSpeech.QUEUE_FLUSH, null);
>> }
>> }
>>
>> I have initialized and used all the methods but unable to get the
>> required output,
>>
>> Can any one tell me how can i overcome this issue and make the speech on
>> a call with user defined message,
>>
>> If possible please advice me the jar that are used to convert text into
>> speech with a simple method,while the phone was ringing,
>>
>> Thanks in advance,
>> Shiva Shankar
>>
>  --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Android Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to