In one method i start a new activity
public void start(){
Intent i = new Intent(mContext, Screen.class);
mContext.startActivity(i);
//Here i want to get the new activity
Activity a = ...
//Do something with new activity
}
After calling starActivity()
i need to get that new Activity and doing something with it.
Is it possible??
EDIT:
Well i have these methods on my Screen class:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
loadedScreen = false;
}
public void loadScreen(String folderResources, String nameXml, String nameScren){
//Do something
}
loadScreen
read an XML file and create by code all user interface, instead of doing in onCreate
In another class I call foo():
public void goToScreen(String nameScreen){
Class screen = Screen.class;
Intent i = new Intent(mContext, screen);
mContext.startActivity(i);
//Here in screen.getMethod... i need use a instance of Screen, which i think it have to be created in `startActivity()`
Method loadUrl = screen.getMethod("loadScreen", String.class, String.class, String.class);
loadUrl.invoke(screen, "folder-s","screen1","screen1.xml");
}
I need call to loadScreen
after startActivity
because this method load all views. I use reflection for doing this. So i need get that new Activity
After calling starActivity() i need to get that new Activity and doing something with it.
Once you call startActivity()
, the other activity does not yet exist -- it will not exist for some time.
I need call to loadScreen after startActivitybecause this method load all views.
Call loadScreen()
from onCreate()
of the Screen
activity.
If you wish to pass the values of folderResources
, nameXml
, and nameScren
to Screen
, do so by calling putExtra()
on the Intent
you use with startActivity()
. Then, Screen
can call getIntent().getStringExtra()
in onCreate()
to retrieve those values, in order to pass them to loadScreen()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With