i have two class, MainActivity and InputAddress, how to load url from class InputAddress
view.loadUrl("here, im confused");
i have two class, MainActivity and InputAddress, how to load url from class InputAddress
view.loadUrl("here, im confused");
send data from inputAddrss,
Intent intent = new Intent(getBaseContext(), SignoutActivity.class);
intent.putExtra("url", YOUR_EDIT_TEXT.getText().toString());
startActivity(intent);
receive data in MainActivity,
String s = getIntent().getStringExtra("url");
then load into webview
view.loadUrl(s);
You can add a public static variable like this:
public class InputAddress {
public static String address = "abc";
}
then you can access the address
variable in MainActivity
like this:
public class MainActivity {
// ...
public void onCreate(....) {
Log.d("TAG", InputAddress.address);
}
}
Hi Deki Kurnia Hadi Permana,
There are lots of way to transfer data from one class to another class, But for the activity no need to do anything they provide functionality to transfer data one to another activity using "Intent" data,
Following is the code where you can send and access data in another activity.
FirstActivity.class
Intent callIntent=new Intent(FirstActivity.this,SecondActivity.class);
callIntent.putExtra("urlToLaunch","post url here");
startActivity(callIntent);
SecondActivity.class
Bundle bundle=getIntent().getExtras();
if(bundle!=null){
String urlToLaunch=bundle.getString("urlToLaunch");
// set In webbrowser
}