Android的说,来电者姓名 [英] Android say caller name

查看:101
本文介绍了Android的说,来电者姓名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎么能说出呼叫方的名字上接听电话。 https://groups.google.com/forum/#​​!topic/tasker/V_z1YJ6lBGQ http://www.tutorialspoint.com/android/android_text_to_speech.htm 这里提到的东西,但我这样做,我已经收到来电者的名字,现在我想的文本到语音转换中收到的方法。 我用事件处理程序,我送这个名字给其他活动,但它没有透露名字的时候应用程序被关闭。

解决方案

 捆绑包= intent.getExtras();


            如果(空==束)
                    返回;


           字符串状态= bundle.getString(TelephonyManager.EXTRA_STATE);


            如果(incoming_flag ==真){
            如果(state.equalsIgnoreCase(TelephonyManager.EXTRA_STATE_RINGING))
            {

                    ////////测试结束

                    字符串联系号码= bundle.getString(TelephonyManager.EXTRA_INCOMING_NUMBER);
                  //字符串PersonName的= bundle.getString(TelephonyManager。)
                    Log.i(IncomingCallReceiver,Incomng数量:+联系号码);
                    ContentResolver的CON = NULL;


                    //测试名
                    开放的我们的uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI,Uri.en code(联系号码));

                    光标光标= context.getContentResolver()查询(URI,新的String [] {} PhoneLookup.DISPLAY_NAME,NULL,NULL,NULL);
                    如果(cursor.moveToFirst())
                    {
                         名称= cursor.getString(cursor.getColumnIndex(PhoneLookup.DISPLAY_NAME));
                    }
 

您必须生成一个播出它来检测来电使用onRecieve参数的意图得到命名上面的示例code说明做的话,你就必须写一个服务,将启动从广播电视到玩来电者姓名使用文本到语音的方法

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.

解决方案

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

这篇关于Android的说,来电者姓名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆