I have a widget and an activity, when I start the activity, I have to read text from the TextView of the widget and show it in the TextWidget of the activity.
My relevant code:
String frase="";
TextView text_frase = (TextView) findViewById(R.id.widget_textview_frase);
if (text_frase != null){
frase = (String) text_frase.getText();
}
Log.v(LOG_CLASS_NAME, "frase: "+frase);
debugging it – I have text_frase as null (I think I can’t reference to a view object from another view.) Anyway, how could I do this?
No, you can’t. I suggest one of this ways:
in your widget:
in your activity:
In your situation, I recommend method 1.