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);
}
Either intents as suggested by Ortisi. Or Why don’t you try creating a class, create that method in this class, And call that method from both the activity.