在一种方法中,我开始一项新活动
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
}
打电话后starActivity()
我需要得到那个新的活动并用它做点什么。
是否可以??
编辑:
好吧,我的 Screen 类上有这些方法:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
loadedScreen = false;
}
public void loadScreen(String folderResources, String nameXml, String nameScren){
//Do something
}
loadScreen
读取 XML 文件并通过代码创建所有用户界面,而不是在onCreate
在另一个类中,我调用 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");
}
我需要调用loadScreen
afterstartActivity
因为此方法加载所有视图。我使用反射来做到这一点。所以我需要获得新的活动