从startActivity开始深入
来源:互联网 发布:犀牛门户源码 编辑:程序博客网 时间:2024/06/01 09:20
startActivity(new Intent(ActivityOne.this, ActivityTwo.class));
1.首先了解传入的参数Intent
public Intent(Context packageContext, Class<?> cls) { mComponent = new ComponentName(packageContext, cls); }
Intent的构造函数里用到了ComponentName对象
public ComponentName(Context pkg, Class<?> cls) { mPackage = pkg.getPackageName(); mClass = cls.getName(); }
这里获取的是当前应用的包名和跳转的Activity的类名
2.回到startActivity(Intent intent)
public void startActivity(Intent intent) { this.startActivity(intent, null); }
public void startActivity(Intent intent, @Nullable Bundle options) { if (options != null) { startActivityForResult(intent, -1, options); } else { // Note we want to go through this call for compatibility with // applications that may have overridden the method. startActivityForResult(intent, -1); } }
这里判断传入的Bundle是否为空,如果为空,就跑下面
public void startActivityForResult(Intent intent, int requestCode) { startActivityForResult(intent, requestCode, null); }
public void startActivityForResult(Intent intent, int requestCode, @Nullable Bundle options) { if (mParent == null) { Instrumentation.ActivityResult ar = mInstrumentation.execStartActivity( this, mMainThread.getApplicationThread(), mToken, this, intent, requestCode, options); if (ar != null) { mMainThread.sendActivityResult( mToken, mEmbeddedID, requestCode, ar.getResultCode(), ar.getResultData()); } if (requestCode >= 0) { // If this start is requesting a result, we can avoid making // the activity visible until the result is received. Setting // this code during onCreate(Bundle savedInstanceState) or onResume() will keep the // activity hidden during this time, to avoid flickering. // This can only be done when a result is requested because // that guarantees we will get information back when the // activity is finished, no matter what happens to it. mStartedActivity = true; } final View decor = mWindow != null ? mWindow.peekDecorView() : null; if (decor != null) { decor.cancelPendingInputEvents(); } // TODO Consider clearing/flushing other event sources and events for child windows. } else { if (options != null) { mParent.startActivityFromChild(this, intent, requestCode, options); } else { // Note we want to go through this method for compatibility with // existing applications that may have overridden it. mParent.startActivityFromChild(this, intent, requestCode); } } if (options != null && !isTopOfTask()) { mActivityTransitionState.startExitOutTransition(this, options); } }
先看parent为空吧,parent也是Activity,应该是一些嵌套Activity组
Instrumentation.ActivityResult ar = mInstrumentation.execStartActivity( this, mMainThread.getApplicationThread(), mToken, this, intent, requestCode, options);
Instrumentation从attach方法那里传进来
final void attach(Context context, ActivityThread aThread, Instrumentation instr, IBinder token, int ident, Application application, Intent intent, ActivityInfo info, CharSequence title, Activity parent, String id, NonConfigurationInstances lastNonConfigurationInstances, Configuration config, String referrer, IVoiceInteractor voiceInteractor) { mInstrumentation = instr;
0 0
- 从startActivity开始深入
- 深入了解startActivity启动流程
- 从Hello World开始深入Ajax
- Spring深入理解之一,从概念开始
- 深入了解物联网,从LoRa开始
- StartActivity
- StartActivity
- startActivity
- 从 startActivity 看activity启动流程
- 从startActivity一步步到穿越进程壁垒
- 从usb storage开始深入linux2.6驱动
- 「深入理解计算系统」从Hello World开始
- 深入理解BootStrap Item1 -- 学习从现在开始
- 深入理解BootStrap -- 学习从现在开始1
- C#总结-从抚摸“Console.WriteLine”开始的逐渐深入
- 深入理解计算系统」从Hello World开始
- CNTK从入门到深入研究(1) - 一切都从介绍和环境搭建开始
- android 项目从后台跳到前台坑点。getApplication().startActivity 和 activity.startActivity
- GitHub上史上最全的iOS开源项目分类汇总
- android:windowSoftInputMode属性详解
- 移动端根据设备大小设置字体大小(居于案例的理解扩展)
- Swagger+Spring MVC框架学习分享
- Linux系统中的at命令的用法
- 从startActivity开始深入
- Tomcat单机多实例配置
- PHP Reflection API是PHP5才有的新功能
- RecyclerView上拉加载,最后一条item被截掉。
- linux部署jar(jenkins包动态)
- Java中多线程原理详解
- scala map/list/array/的常用内置遍历操作总结
- ACM天梯赛 L3-02 堆栈(线段树)
- Android 'M' Doze