1.LocaActivityManager am = new LocalActivityManager(Context,true);
2.Window window = am.startActivity("tag",new Intent());
3.View view = window.getDecorView();
接下来一定要在3个生命周期函数里调用如下方法,否则会抛出异常:java.lang.IllegalStateException: Activities can‘t be added until the containing group has been created.
onCreate()方法里调用am.dispatchCreate(savedInstanceState);
onPause()方法里调用am.dispatchPause(true);
onResume()方法里调用am.dispatchResume();
时间: 2024-10-06 15:59:53