I have an activity which, when an item is selected. Starts a new thread setting the active call forwarding number and sets this number as the text of a TextView in another activity.
I tried this:
newnumber[0] = ((TextView) view).getText().toString();
new PushNumberTask().execute(newnumber);
TextView activeNumberTV = (TextView) findViewById(R.id.activeNumberTextView);
activeNumberTV.setText(newnumber[0]);
But I’m getting a NullPointerException whenever it tries to set the text. What silly mistake am I making? I should mention that the number is in fact being changed on the server and in the user info. It’s just that updating the text field from another activity is causing the exception.
EDIT: Simplified my problem a bit(i hope). I have a model class with SharedPreferences userInfo.getString(“number”)
I want to notify a TextView whenever this string is updated/changed. How do I go about doing this ?
This is very bad practice.. What i would do is i’ll send it through intent or use getter setter in some data class and when that activity comes to foreground i would set its Text… you can set it in
onActivityResult(), oronResume()methods