Reputation:
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);
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);
the TextView remains blank.
Any suggestions as to why this is happening?
Upvotes: 1
Views: 1040
Reputation:
Found the answer! http://android-journey.blogspot.com/2010/01/android-braodcast-receivers.html
What I did was I created a String method for:
intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER)
to grab the phone number and return it. So in the class with my custom screen, I did this:
IncomingCallListener ICL = new IncomingCallListener();
textView_incomingNumber.setText(ICL.getPhoneNumber());
Now my custom screen shows the incoming phone number in the textview
Upvotes: 0
Reputation: 34301
if phoneNr is integer do it like ""+phoneNr
,
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
Upvotes: 1