Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

How can I say caller name on receiving call. https://groups.google.com/forum/#!topic/tasker/V_z1YJ6lBGQ http://www.tutorialspoint.com/android/android_text_to_speech.htm There is something mentioned but i have done that, i have received caller name, now I want to convert that text to speech in on received method. I did used event handler and i send that name to other activity but it didn't say name when app is closed.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
223 views
Welcome To Ask or Share your Answers For Others

1 Answer

Bundle bundle = intent.getExtras();


            if(null == bundle)
                    return;


           String state = bundle.getString(TelephonyManager.EXTRA_STATE);


            if(incoming_flag==true){
            if(state.equalsIgnoreCase(TelephonyManager.EXTRA_STATE_RINGING))
            {

                    ////////testing ends

                    String phonenumber = bundle.getString(TelephonyManager.EXTRA_INCOMING_NUMBER);
                  //  String personname=bundle.getString(TelephonyManager.)       
                    Log.i("IncomingCallReceiver","Incomng Number: " + phonenumber);
                    ContentResolver con =null;


                    //testing name
                    Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(phonenumber));

                    Cursor cursor = context.getContentResolver().query(uri, new String[]{PhoneLookup.DISPLAY_NAME},null,null,null);
                    if (cursor.moveToFirst())
                    {
                         name = cursor.getString(cursor.getColumnIndex(PhoneLookup.DISPLAY_NAME));
                    }   

You will have to generate a broadcast for it to detect incoming call the use the intent of onRecieve param to get name the above sample code shows the way to do it, you will have to write a service which will start from broadcast to play caller name use text to speech method


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...