面试题库

1. 跨进程的远程方法的是执行在哪个进程的哪个线程?

(都是binder线程池)

2. SharedPreference实现原理,跨进程使用问题,为什么引起这个问题
3. Parcelable和Serializable区别,以及他们实现的原理
4. Binder相较于Socket实现进程通信的有点(拷贝少,安全)
5. A Activity的onCreate中启动一个新的activiy, A Activity的OnResume ,onPause与新Activity生命周期方法的执行顺序

A onCreate, onStart onResume ,onPause .. - > B onCreate, onStart, onResume

MainActivity中点击按钮启动两个Activity:

1
2
startActivity(new Intent(MainActivity.this, ActivityA.class));
startActivity(new Intent(MainActivity.this, ActivityB.class));

生命周期执行情况为:

1
2
3
4
5
6
7
8
9
2019-08-05 11:48:41.132 3557-3557/com.osn.demo I/MainActivityDDDD: onStart....
2019-08-05 11:48:41.133 3557-3557/com.osn.demo I/MainActivityDDDD: onResume....


2019-08-05 11:48:46.257 3557-3557/com.osn.demo I/MainActivityDDDD: onPause....
2019-08-05 11:48:46.271 3557-3557/com.osn.demo I/ActivityBBBB: onCreate...
2019-08-05 11:48:46.280 3557-3557/com.osn.demo I/ActivityBBBB: onStart....
2019-08-05 11:48:46.282 3557-3557/com.osn.demo I/ActivityBBBB: onResume....
2019-08-05 11:48:46.703 3557-3557/com.osn.demo I/MainActivityDDDD: onStop....

返回键关闭ActivityB,执行的生命周期方法:

1
2
3
4
5
6
2019-08-05 11:48:49.760 3557-3557/com.osn.demo I/ActivityBBBB: onPause....
2019-08-05 11:48:49.808 3557-3557/com.osn.demo I/ActivityAAAA: onCreate...
2019-08-05 11:48:49.841 3557-3557/com.osn.demo I/ActivityAAAA: onStart....
2019-08-05 11:48:49.845 3557-3557/com.osn.demo I/ActivityAAAA: onResume....
2019-08-05 11:48:50.227 3557-3557/com.osn.demo I/ActivityBBBB: onStop....
2019-08-05 11:48:50.228 3557-3557/com.osn.demo I/ActivityBBBB: onDestroy....

返回键关闭ActivityA:

1
2
3
4
5
6
2019-08-05 11:48:54.615 3557-3557/com.osn.demo I/ActivityAAAA: onPause....
2019-08-05 11:48:54.655 3557-3557/com.osn.demo I/MainActivityDDDD: onRestart....
2019-08-05 11:48:54.657 3557-3557/com.osn.demo I/MainActivityDDDD: onStart....
2019-08-05 11:48:54.658 3557-3557/com.osn.demo I/MainActivityDDDD: onResume....
2019-08-05 11:48:54.990 3557-3557/com.osn.demo I/ActivityAAAA: onStop....
2019-08-05 11:48:54.990 3557-3557/com.osn.demo I/ActivityAAAA: onDestroy....

结论: 顺序依次start两个Activity,那么会优先最后一个调用的先创建.

6. 同一台主机,udp和tcp可否使用同一个端口

(可以)

7. Android一个最简单的demo程序启动后包含哪些线程
坚持原创技术分享,您的支持将鼓励我继续创作!