为什么不能我设置的TextView显示来电的电话号码? [英] Why cant I set TextView to display incoming call phone number?

查看:109
本文介绍了为什么不能我设置的TextView显示来电的电话号码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,它取代了标准的来电屏幕与我自己设计的。当有人打电话,我的自定义屏幕上弹出。这是好事,但由于某些原因,我的应用程序无法显示来电号码。该来电号码显示在LogCat中,但是当我尝试设置的TextView该字符串,什么也不显示。这里是code表示检索来电号码:

I have an app that replaces the standard incoming call screen with my own design. When someone calls, my custom screen pops up. This is good, but for some reason, my app fails to display the incoming phone number. The incoming phone number shows in LogCat, but when I try to set the TextView to that String, nothing shows. Here is the code that retrieves the incoming phone number:

Bundle extras = intent.getExtras();
    phoneNr = extras.getString("incoming_number");
    Log.v(TAG, "phoneNr: " + phoneNr);

正如你所看到的,字符串phoneNr显示LogCat中的来电号码。但是,当我尝试使用它来设置的TextView的文本在显示我的自定义屏幕的类(IncomingCallRecieved):

As you can see, the String "phoneNr" displays the incoming phone number in LogCat. But when I try to use it to set the text of of the TextView in the class (IncomingCallRecieved) that displays my custom screen:

IncomingCallListener ICL = new IncomingCallListener(); // class for BroadcastReciever
textView_incomingNumber.setText(ICL.phoneNr);

TextView的保持空白。

the TextView remains blank.

任何建议,为什么发生这种情况?

Any suggestions as to why this is happening?

推荐答案

如果phoneNr是整数做到像+ phoneNr

if phoneNr is integer do it like ""+phoneNr ,

也正在新IncomingCallListener()对象将不会提及,实际上得到了number..so要么使这个数字变量类公开静态和直接使用像 classname.variablename

also making new IncomingCallListener() object will not going to refer the class which actually got the number..so either make that number variable public static and directly use that variable like classname.variablename

这篇关于为什么不能我设置的TextView显示来电的电话号码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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