I am calling from activityA a method that is on activityB.
Method is called from A to B properly but when I execute inside it webviewB.loadUrl(myUrl), app crashes for a nullpointerexception. Same webviewB method, if executed from activityB, works properly. Probably is done because context, when calling from A to B must be set, but how? Which is the best way to do it? Thank you.
ActivityA (tabHost) and ActivityB (tabcontent) are initialized properly and webview from ActivityB shows URL1.
Then when evet from ActivityA is recived, I need to load URL2 on webview from ActivityB.
EDIT:
when event is received on ActivityA,
ActivityB test = new ActivityB();
test.recalcula();
ActivityB,
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.vistaaib);
webviewB = (WebView) findViewById(R.id.webviewB);
webviewB.loadUrl(URL1);
...
public void recalcula (){
webviewB.loadUrl(URL2);
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…