├── MarkAsJavaSort.java ├── README-CN.md ├── README.md └── picture ├── algorithm.png ├── architucture.png ├── collection.png ├── fragment-life.png ├── hashmap.jpg └── http.png /MarkAsJavaSort.java: -------------------------------------------------------------------------------- 1 | MarkAsJavaSort 2 | -------------------------------------------------------------------------------- /README-CN.md: -------------------------------------------------------------------------------- 1 | ###欢迎在GitHub或者CSDN上关注我 2 | 3 | GitHub: https://github.com/JackyAndroid 4 | 5 | CSDN: http://blog.csdn.net/rain_butterfly 6 | 7 | --- 8 | 9 | # 国内一线互联网公司内部面试题库 10 | 以下面试题来自于百度、小米、乐视、美团、58、猎豹、360、新浪、搜狐内部题库 11 | 12 | 熟悉本文中列出的知识点会大大增加通过前两轮技术面试的几率。 13 | 14 | 欢迎一线公司员工提交内部面试题库,欢迎star。 15 | ##目录 16 | * [java基础](#java) 17 | * [接口的意义-百度](#接口的意义-百度) 18 | * [抽象类的意义-乐视](#抽象类的意义-乐视) 19 | * [内部类的作用-乐视](#内部类的作用-乐视) 20 | * [父类的静态方法能否被子类重写-猎豹](#父类的静态方法能否被子类重写-猎豹) 21 | * [java排序算法-美团](#java排序算法-美团) 22 | * [列举java的集合和继承关系-百度-美团](#列举java的集合和继承关系-百度-美团) 23 | * [java虚拟机的特性-百度-乐视](#java虚拟机的特性-百度-乐视) 24 | * [哪些情况下的对象会被垃圾回收机制处理掉-美团-小米](#哪些情况下的对象会被垃圾回收机制处理掉-美团-小米) 25 | * [进程和线程的区别-猎豹-美团](#进程和线程的区别-猎豹-美团) 26 | * [==和equals和hashCode的区别-乐视](#java中==和equals和hashCode的区别-乐视) 27 | * [常见的排序算法时间复杂度-小米](#常见的排序算法时间复杂度-小米) 28 | * [HashMap的实现原理-美团](#HashMap的实现原理-美团) 29 | * [java状态机](#java状态机) 30 | * [int-char-long各占多少字节数](#int-char-long各占多少字节数) 31 | * [int与integer的区别](#int与integer的区别) 32 | * [string-stringbuffer-stringbuilder区别-小米-乐视-百度](#string-stringbuffer-stringbuilder区别-小米-乐视-百度) 33 | * [java多态-乐视](#java多态-乐视) 34 | * [什么导致线程阻塞-58-美团](#什么导致线程阻塞-58-美团) 35 | * [抽象类接口区别-360](#抽象类接口区别-360) 36 | * [容器类之间的区别-乐视-美团](#容器类之间的区别-乐视-美团) 37 | * [内部类](#内部类) 38 | * [hashmap和hashtable的区别-乐视-小米](#hashmap和hashtable的区别-乐视-小米) 39 | * [ArrayMap对比HashMap](#arraymap对比hashmap) 40 | * [安卓](#android) 41 | 42 | ###java 43 | 44 | ####接口的意义-百度 45 | 46 | 规范、扩展、回调 47 | 48 | ####抽象类的意义-乐视 49 | 50 | 为其子类提供一个公共的类型 51 | 封装子类中得重复内容 52 | 定义抽象方法,子类虽然有不同的实现 但是定义是一致的 53 | 54 | ####内部类的作用-乐视 55 | 56 | 1. 内部类可以用多个实例,每个实例都有自己的状态信息,并且与其他外围对象的信息相互独立。 57 | 2. 在单个外围类中,可以让多个内部类以不同的方式实现同一个接口,或者继承同一个类。 58 | 3. 创建内部类对象的时刻并不依赖于外围类对象的创建。 59 | 4. 内部类并没有令人迷惑的“is-a”关系,他就是一个独立的实体。 60 | 5. 内部类提供了更好的封装,除了该外围类,其他类都不能访问 61 | 62 | ####父类的静态方法能否被子类重写-猎豹 63 | 64 | 不能 65 | 66 | 子类继承父类后,用相同的静态方法和非静态方法,这时非静态方法覆盖父类中的方法(即方法重写),父类的该静态方法被隐藏(如果对象是父类则调用该隐藏的方法),另外子类可继承父类的静态与非静态方法,至于方法重载我觉得它其中一要素就是在同一类中,不能说父类中的什么方法与子类里的什么方法是方法重载的体现 67 | 68 | ####java排序算法-美团 69 | 70 | http://blog.csdn.net/qy1387/article/details/7752973 71 | 72 | ####列举java的集合和继承关系-百度-美团 73 | 74 | ![](https://github.com/JackyAndroid/AndroidInterview-Q-A/blob/master/picture/collection.png) 75 | 76 | ####java虚拟机的特性-百度-乐视 77 | 78 | Java语言的一个非常重要的特点就是与平台的无关性。而使用Java虚拟机是实现这一特点的关键。一般的高级语言如果要在不同的平台上运行,至少需要编译成不同的目标代码。而引入Java语言虚拟机后,Java语言在不同平台上运行时不需要重新编译。Java语言使用模式Java虚拟机屏蔽了与具体平台相关的信息,使得Java语言编译程序只需生成在Java虚拟机上运行的目标代码(字节码),就可以在多种平台上不加修改地运行。Java虚拟机在执行字节码时,把字节码解释成具体平台上的机器指令执行。 79 | 80 | ####哪些情况下的对象会被垃圾回收机制处理掉-美团-小米 81 | 82 | Java 垃圾回收机制最基本的做法是分代回收。内存中的区域被划分成不同的世代,对象根据其存活的时间被保存在对应世代的区域中。一般的实现是划分成3个世代:年轻、年老和永久。内存的分配是发生在年轻世代中的。当一个对象存活时间足够长的时候,它就会被复制到年老世代中。对于不同的世代可以使用不同的垃圾回收算法。进行世代划分的出发点是对应用中对象存活时间进行研究之后得出的统计规律。一般来说,一个应用中的大部分对象的存活时间都很短。比如局部变量的存活时间就只在方法的执行过程中。基于这一点,对于年轻世代的垃圾回收算法就可以很有针对性。 83 | 84 | ####进程和线程的区别-猎豹-美团 85 | 86 | 简而言之,一个程序至少有一个进程,一个进程至少有一个线程。 87 | 88 | 线程的划分尺度小于进程,使得多线程程序的并发性高。 89 | 90 | 另外,进程在执行过程中拥有独立的内存单元,而多个线程共享内存,从而极大地提高了程序的运行效率。 91 | 92 | 线程在执行过程中与进程还是有区别的。每个独立的线程有一个程序运行的入口、顺序执行序列和程序的出口。但是线程不能够独立执行,必须依存在应用程序中,由应用程序提供多个线程执行控制。 93 | 94 | 从逻辑角度来看,多线程的意义在于一个应用程序中,有多个执行部分可以同时执行。但操作系统并没有将多个线程看做多个独立的应用,来实现进程的调度和管理以及资源分配。这就是进程和线程的重要区别。 95 | 96 | 进程是具有一定独立功能的程序关于某个数据集合上的一次运行活动,进程是系统进行资源分配和调度的一个独立单位. 97 | 98 | 线程是进程的一个实体,是CPU调度和分派的基本单位,它是比进程更小的能独立运行的基本单位.线程自己基本上不拥有系统资源,只拥有一点在运行中必不可少的资源(如程序计数器,一组寄存器和栈),但是它可与同属一个进程的其他的线程共享进程所拥有的全部资源. 99 | 100 | 一个线程可以创建和撤销另一个线程;同一个进程中的多个线程之间可以并发执行. 101 | 102 | 进程和线程的主要差别在于它们是不同的操作系统资源管理方式。进程有独立的地址空间,一个进程崩溃后,在保护模式下不会对其它进程产生影响,而线程只是一个进程中的不同执行路径。线程有自己的堆栈和局部变量,但线程之间没有单独的地址空间,一个线程死掉就等于整个进程死掉,所以多进程的程序要比多线程的程序健壮,但在进程切换时,耗费资源较大,效率要差一些。但对于一些要求同时进行并且又要共享某些变量的并发操作,只能用线程,不能用进程。如果有兴趣深入的话,我建议你们看看《现代操作系统》或者《操作系统的设计与实现》。对就个问题说得比较清楚。 103 | 104 | ####java中==和equals和hashCode的区别-乐视 105 | 106 | http://blog.csdn.net/tiantiandjava/article/details/46988461 107 | 108 | ####常见的排序算法时间复杂度-小米 109 | 110 | ![](https://github.com/JackyAndroid/AndroidInterview-Q-A/blob/master/picture/algorithm.png) 111 | 112 | ####HashMap的实现原理-美团 113 | 114 | 1. HashMap概述: 115 |    HashMap是基于哈希表的Map接口的非同步实现。此实现提供所有可选的映射操作,并允许使用null值和null键。此类不保证映射的顺序,特别是它不保证该顺序恒久不变。 116 | 2. HashMap的数据结构: 117 | 在java编程语言中,最基本的结构就是两种,一个是数组,另外一个是模拟指针(引用),所有的数据结构都可以用这两个基本结构来构造的,HashMap也不例外。HashMap实际上是一个“链表散列”的数据结构,即数组和链表的结合体。 118 | 119 | ![](https://github.com/JackyAndroid/AndroidInterview-Q-A/blob/master/picture/hashmap.jpg) 120 | 121 | 从上图中可以看出,HashMap底层就是一个数组结构,数组中的每一项又是一个链表。当新建一个HashMap的时候,就会初始化一个数组。 122 | 123 | ####状态机 124 | 125 | http://www.jdon.com/designpatterns/designpattern_State.htm 126 | 127 | ####int-char-long各占多少字节数 128 | 129 | byte 位数 8 字节数 1 130 | 131 | short 16 2 132 | 133 | int 32 4 134 | 135 | long 64 8 136 | 137 | float 32 4 138 | 139 | double 64 8 140 | 141 | char 16 2 142 | 143 | ####int与integer的区别 144 | 145 | http://www.cnblogs.com/shenliang123/archive/2011/10/27/2226903.html 146 | 147 | ####string-stringbuffer-stringbuilder区别-小米-乐视-百度 148 | 149 | String 字符串常量 150 | 151 | StringBuffer 字符串变量(线程安全) 152 | 153 | StringBuilder 字符串变量(非线程安全) 154 | 155 | 简要的说, String 类型和 StringBuffer 类型的主要性能区别其实在于 String 是不可变的对象, 因此在每次对 String 类型进行改变的时候其实都等同于生成了一个新的 String 对象,然后将指针指向新的 String 对象,所以经常改变内容的字符串最好不要用String ,因为每次生成对象都会对系统性能产生影响,特别当内存中无引用对象多了以后,JVM 的 GC 就会开始工作,那速度是一定会相当慢的。 156 | 157 | 而如果是使用 StringBuffer 类则结果就不一样了,每次结果都会对 StringBuffer 对象本身进行操作,而不是生成新的对象,再改变对象引用。所以在一般情况下我们推荐使用 StringBuffer ,特别是字符串对象经常改变的情况下。而在某些特别情况下, String 对象的字符串拼接其实是被 JVM 解释成了 StringBuffer 对象的拼接,所以这些时候 String 对象的速度并不会比 StringBuffer 对象慢,而特别是以下的字符串对象生成中, String 效率是远要比 StringBuffer 快的: 158 | 159 | String S1 = “This is only a” + “ simple” + “ test”; 160 | 161 | StringBuffer Sb = new StringBuilder(“This is only a”).append(“ simple”).append(“ test”); 162 | 你会很惊讶的发现,生成 String S1 对象的速度简直太快了,而这个时候 StringBuffer 居然速度上根本一点都不占优势。其实这是 JVM 的一个把戏,在 JVM 眼里,这个 163 |  String S1 = “This is only a” + “ simple” + “test”; 其实就是: 164 |  String S1 = “This is only a simple test”; 所以当然不需要太多的时间了。但大家这里要注意的是,如果你的字符串是来自另外的 String 对象的话,速度就没那么快了,譬如: 165 |  String S2 = “This is only a”; 166 | String S3 = “ simple”; 167 | String S4 = “ test”; 168 | String S1 = S2 +S3 + S4; 169 | 这时候 JVM 会规规矩矩的按照原来的方式去做 170 | 171 | 在大部分情况下 StringBuffer > String 172 | 173 | StringBuffer 174 | 175 | Java.lang.StringBuffer线程安全的可变字符序列。一个类似于 String 的字符串缓冲区,但不能修改。虽然在任意时间点上它都包含某种特定的字符序列,但通过某些方法调用可以改变该序列的长度和内容。 176 | 177 | 可将字符串缓冲区安全地用于多个线程。可以在必要时对这些方法进行同步,因此任意特定实例上的所有操作就好像是以串行顺序发生的,该顺序与所涉及的每个线程进行的方法调用顺序一致。 178 | 179 | StringBuffer 上的主要操作是 append 和 insert 方法,可重载这些方法,以接受任意类型的数据。每个方法都能有效地将给定的数据转换成字符串,然后将该字符串的字符追加或插入到字符串缓冲区中。append 方法始终将这些字符添加到缓冲区的末端;而 insert 方法则在指定的点添加字符。 180 | 181 | 例如,如果 z 引用一个当前内容是“start”的字符串缓冲区对象,则此方法调用 z.append("le") 会使字符串缓冲区包含“startle”,而 z.insert(4, "le") 将更改字符串缓冲区,使之包含“starlet”。 182 | 183 | 在大部分情况下 StringBuilder > StringBuffer 184 | 185 | java.lang.StringBuilder 186 | 187 | java.lang.StringBuilder一个可变的字符序列是5.0新增的。此类提供一个与 StringBuffer 兼容的 API,但不保证同步。该类被设计用作 StringBuffer 的一个简易替换,用在字符串缓冲区被单个线程使用的时候(这种情况很普遍)。如果可能,建议优先采用该类,因为在大多数实现中,它比 StringBuffer 要快。两者的方法基本相同 188 | 189 | ####java多态-乐视 190 | 191 | Java多态性理解 192 | 193 | Java中多态性的实现 194 | 195 | 什么是多态 196 | 197 | 面向对象的三大特性:封装、继承、多态。从一定角度来看,封装和继承几乎都是为多态而准备的。这是我们最后一个概念,也是最重要的知识点。 198 | 199 | 多态的定义:指允许不同类的对象对同一消息做出响应。即同一消息可以根据发送对象的不同而采用多种不同的行为方式。(发送消息就是函数调用) 200 | 201 | 实现多态的技术称为:动态绑定(dynamic binding),是指在执行期间判断所引用对象的实 202 | 际类型,根据其实际的类型调用其相应的方法。 203 | 204 | 多态的作用:消除类型之间的耦合关系。 205 | 206 | 现实中,关于多态的例子不胜枚举。比方说按下 F1 键这个动作,如果当前在 Flash 界面下弹出的就是 AS 3 的帮助文档;如果当前在 Word 下弹出的就是 Word 帮助;在 Windows 下弹出的就是 Windows 帮助和支持。同一个事件发生在不同的对象上会产生不同的结果。 207 | 下面是多态存在的三个必要条件,要求大家做梦时都能背出来! 208 | 209 | 多态存在的三个必要条件 210 | 一、要有继承; 211 | 二、要有重写; 212 | 三、父类引用指向子类对象。 213 | 214 |  多态的好处: 215 | 216 | 1.可替换性(substitutability)。多态对已存在代码具有可替换性。例如,多态对圆Circle类工作,对其他任何圆形几何体,如圆环,也同样工作。 217 | 218 | 2.可扩充性(extensibility)。多态对代码具有可扩充性。增加新的子类不影响已存在类的多态性、继承性,以及其他特性的运行和操作。实际上新加子类更容易获得多态功能。例如,在实现了圆锥、半圆锥以及半球体的多态基础上,很容易增添球体类的多态性。 219 | 220 | 3.接口性(interface-ability)。多态是超类通过方法签名,向子类提供了一个共同接口,由子类来完善或者覆盖它而实现的。如图8.3 所示。图中超类Shape规定了两个实现多态的接口方法,computeArea()以及computeVolume()。子类,如Circle和Sphere为了实现多态,完善或者覆盖这两个接口方法。 221 | 222 | 4.灵活性(flexibility)。它在应用中体现了灵活多样的操作,提高了使用效率。 223 | 224 | 5.简化性(simplicity)。多态简化对应用软件的代码编写和修改过程,尤其在处理大量对象的运算和操作时,这个特点尤为突出和重要。 225 | 226 | Java中多态的实现方式:接口实现,继承父类进行方法重写,同一个类中进行方法重载。 227 | 228 | ####什么导致线程阻塞-58-美团 229 | 230 | 线程的阻塞 231 | 232 | 为了解决对共享存储区的访问冲突,Java 引入了同步机制,现在让我们来考察多个线程对共享资源的访问,显然同步机制已经不够了,因为在任意时刻所要求的资源不一定已经准备好了被访问,反过来,同一时刻准备好了的资源也可能不止一个。为了解决这种情况下的访问控制问题,Java 引入了对阻塞机制的支持. 233 | 234 | 阻塞指的是暂停一个线程的执行以等待某个条件发生(如某资源就绪),学过操作系统的同学对它一定已经很熟悉了。Java 提供了大量方法来支持阻塞,下面让我们逐一分析。 235 | 236 | 1. sleep() 方法:sleep() 允许 指定以毫秒为单位的一段时间作为参数,它使得线程在指定的时间内进入阻塞状态,不能得到CPU 时间,指定的时间一过,线程重新进入可执行状态。 237 | 典型地,sleep() 被用在等待某个资源就绪的情形:测试发现条件不满足后,让线程阻塞一段时间后重新测试,直到条件满足为止。 238 | 2. suspend() 和 resume() 方法:两个方法配套使用,suspend()使得线程进入阻塞状态,并且不会自动恢复,必须其对应的resume() 被调用,才能使得线程重新进入可执行状态。典型地,suspend() 和 resume() 被用在等待另一个线程产生的结果的情形:测试发现结果还没有产生后,让线程阻塞,另一个线程产生了结果后,调用 resume() 使其恢复。 239 | 3. yield() 方法:yield() 使得线程放弃当前分得的 CPU 时间,但是不使线程阻塞,即线程仍处于可执行状态,随时可能再次分得 CPU 时间。调用 yield() 的效果等价于调度程序认为该线程已执行了足够的时间从而转到另一个线程. 240 | 4. wait() 和 notify() 方法:两个方法配套使用,wait() 使得线程进入阻塞状态,它有两种形式,一种允许 指定以毫秒为单位的一段时间作为参数,另一种没有参数,前者当对应的 notify() 被调用或者超出指定时间时线程重新进入可执行状态,后者则必须对应的 notify() 被调用. 241 | 242 | 初看起来它们与 suspend() 和 resume() 方法对没有什么分别,但是事实上它们是截然不同的。区别的核心在于,前面叙述的所有方法,阻塞时都不会释放占用的锁(如果占用了的话),而这一对方法则相反。 243 | 244 | 上述的核心区别导致了一系列的细节上的区别。 245 | 246 | 首先,前面叙述的所有方法都隶属于 Thread 类,但是这一对却直接隶属于 Object 类,也就是说,所有对象都拥有这一对方法。初看起来这十分不可思议,但是实际上却是很自然的,因为这一对方法阻塞时要释放占用的锁,而锁是任何对象都具有的,调用任意对象的 wait() 方法导致线程阻塞,并且该对象上的锁被释放。而调用 任意对象的notify()方法则导致因调用该对象的 wait() 方法而阻塞的线程中随机选择的一个解除阻塞(但要等到获得锁后才真正可执行)。 247 | 248 | 其次,前面叙述的所有方法都可在任何位置调用,但是这一对方法却必须在 synchronized 方法或块中调用,理由也很简单,只有在synchronized 方法或块中当前线程才占有锁,才有锁可以释放。同样的道理,调用这一对方法的对象上的锁必须为当前线程所拥有,这样才有锁可以释放。因此,这一对方法调用必须放置在这样的 synchronized 方法或块中,该方法或块的上锁对象就是调用这一对方法的对象。若不满足这一条件,则程序虽然仍能编译,但在运行时会出现IllegalMonitorStateException 异常。 249 | 250 | wait() 和 notify() 方法的上述特性决定了它们经常和synchronized 方法或块一起使用,将它们和操作系统的进程间通信机制作一个比较就会发现它们的相似性:synchronized方法或块提供了类似于操作系统原语的功能,它们的执行不会受到多线程机制的干扰,而这一对方法则相当于 block 和wakeup 原语(这一对方法均声明为 synchronized)。它们的结合使得我们可以实现操作系统上一系列精妙的进程间通信的算法(如信号量算法),并用于解决各种复杂的线程间通信问题。 251 | 252 | 关于 wait() 和 notify() 方法最后再说明两点: 253 | 254 | 第一:调用 notify() 方法导致解除阻塞的线程是从因调用该对象的 wait() 方法而阻塞的线程中随机选取的,我们无法预料哪一个线程将会被选择,所以编程时要特别小心,避免因这种不确定性而产生问题。 255 | 256 | 第二:除了 notify(),还有一个方法 notifyAll() 也可起到类似作用,唯一的区别在于,调用 notifyAll() 方法将把因调用该对象的 wait() 方法而阻塞的所有线程一次性全部解除阻塞。当然,只有获得锁的那一个线程才能进入可执行状态。 257 | 258 | 谈到阻塞,就不能不谈一谈死锁,略一分析就能发现,suspend() 方法和不指定超时期限的 wait() 方法的调用都可能产生死锁。遗憾的是,Java 并不在语言级别上支持死锁的避免,我们在编程中必须小心地避免死锁。 259 | 260 | 以上我们对 Java 中实现线程阻塞的各种方法作了一番分析,我们重点分析了 wait() 和 notify() 方法,因为它们的功能最强大,使用也最灵活,但是这也导致了它们的效率较低,较容易出错。实际使用中我们应该灵活使用各种方法,以便更好地达到我们的目的。 261 | 262 | ####抽象类接口区别-360 263 | 264 | 1. 默认的方法实现 265 | 抽象类可以有默认的方法实现完全是抽象的。接口根本不存在方法的实现 266 | 267 | 2. 实现 268 | 子类使用extends关键字来继承抽象类。如果子类不是抽象类的话,它需要提供抽象类中所有声明的方法的实现。 269 | 子类使用关键字implements来实现接口。它需要提供接口中所有声明的方法的实现 270 | 271 | 3. 构造器 272 | 抽象类可以有构造器 273 | 接口不能有构造器 274 | 275 | 4. 与正常Java类的区别 276 | 除了你不能实例化抽象类之外,它和普通Java类没有任何区 277 | 接口是完全不同的类型 278 | 279 | 5. 访问修饰符 280 | 抽象方法可以有public、protected和default这些修饰符 281 | 接口方法默认修饰符是public。你不可以使用其它修饰符。 282 | 283 | 6. main方法 284 | 抽象方法可以有main方法并且我们可以运行它 285 | 接口没有main方法,因此我们不能运行它。 286 | 287 | 7. 多继承 288 | 抽象类在java语言中所表示的是一种继承关系,一个子类只能存在一个父类,但是可以存在多个接口。 289 | 290 | 8. 速度 291 | 它比接口速度要快 292 | 接口是稍微有点慢的,因为它需要时间去寻找在类中实现的方法。 293 | 294 | 9. 添加新方法 295 | 如果你往抽象类中添加新的方法,你可以给它提供默认的实现。因此你不需要改变你现在的代码。 296 | 如果你往接口中添加方法,那么你必须改变实现该接口的类。 297 | 298 | ####容器类之间的区别-乐视-美团 299 | 300 | http://www.cnblogs.com/yuanermen/archive/2009/08/05/1539917.html 301 | http://alexyyek.github.io/2015/04/06/Collection/ 302 | http://tianmaying.com/tutorial/java_collection 303 | 304 | ####内部类 305 | 306 | http://www.cnblogs.com/chenssy/p/3388487.html 307 | 308 | ####hashmap和hashtable的区别-乐视-小米 309 | 310 | http://www.233.com/ncre2/JAVA/jichu/20100717/084230917.html 311 | 312 | ####ArrayMap对比HashMap 313 | 314 | http://lvable.com/?p=217 315 | 316 | ###Android 317 | 318 | **1.数据库的操作类型有哪些,如何导入外部数据库?** 319 | 320 | 把原数据库包括在项目源码的 res/raw 321 | 322 | android系统下数据库应该存放在 /data/data/com.*.*(package name)/ 目录下,所以我们需要做的是把已有的数据库传入那个目录下.操作方法是用FileInputStream读取原数据库,再用FileOutputStream把读取到的东西写入到那个目录. 323 | 324 | **2.是否使用过本地广播,和全局广播有什么差别?** 325 | 326 | 因广播数据在本应用范围内传播,不用担心隐私数据泄露的问题。 327 | 不用担心别的应用伪造广播,造成安全隐患。 328 | 相比在系统内发送全局广播,它更高效。 329 | 330 | **3.是否使用过intentService,作用是什么,AIDL解决了什么问题?**(小米) 331 | 332 | 生成一个默认的且与主线程互相独立的工作者线程来执行所有传送至onStartCommand() 方法的Intetnt。 333 | 334 | 生成一个工作队列来传送Intent对象给你的onHandleIntent()方法,同一时刻只传送一个Intent对象,这样一来,你就不必担心多线程的问题。在所有的请求(Intent)都被执行完以后会自动停止服务,所以,你不需要自己去调用stopSelf()方法来停止。 335 | 336 | 该服务提供了一个onBind()方法的默认实现,它返回null 337 | 338 | 提供了一个onStartCommand()方法的默认实现,它将Intent先传送至工作队列,然后从工作队列中每次取出一个传送至onHandleIntent()方法,在该方法中对Intent对相应的处理。 339 | 340 | AIDL (Android Interface Definition Language) 是一种IDL 语言,用于生成可以在Android设备上两个进程之间进行进程间通信(interprocess communication, IPC)的代码。如果在一个进程中(例如Activity)要调用另一个进程中(例如Service)对象的操作,就可以使用AIDL生成可序列化的参数。 341 | AIDL IPC机制是面向接口的,像COM或Corba一样,但是更加轻量级。它是使用代理类在客户端和实现端传递数据。 342 | 343 | **4.Activity、Window、View三者的差别,fragment的特点?**(360) 344 | 345 | Activity像一个工匠(控制单元),Window像窗户(承载模型),View像窗花(显示视图) 346 | LayoutInflater像剪刀,Xml配置像窗花图纸。 347 | 348 | 1. 在Activity中调用attach,创建了一个Window 349 | 2. 创建的window是其子类PhoneWindow,在attach中创建PhoneWindow 350 | 3. 在Activity中调用setContentView(R.layout.xxx) 351 | 4. 其中实际上是调用的getWindow().setContentView() 352 | 5. 调用PhoneWindow中的setContentView方法 353 | 6. 创建ParentView:
作为ViewGroup的子类,实际是创建的DecorView(作为FramLayout的子类) 354 | 7. 将指定的R.layout.xxx进行填充
通过布局填充器进行填充【其中的parent指的就是DecorView】 355 | 8. 调用到ViewGroup 356 | 9. 调用ViewGroup的removeAllView(),先将所有的view移除掉 357 | 10. 添加新的view:addView() 358 | 359 | fragment 特点 360 | 361 | * Fragment可以作为Activity界面的一部分组成出现; 362 | * 可以在一个Activity中同时出现多个Fragment,并且一个Fragment也可以在多个Activity中使用; 363 | * 在Activity运行过程中,可以添加、移除或者替换Fragment; 364 | * Fragment可以响应自己的输入事件,并且有自己的生命周期,它们的生命周期会受宿主Activity的生命周期影响。 365 | 366 | **5.描述一次网络请求的流程**(新浪) 367 | 368 | ![](https://github.com/JackyAndroid/AndroidInterview-Q-A/blob/master/picture/http.png) 369 | 370 | **6.Handler、Thread和HandlerThread的差别**(小米) 371 | 372 | http://blog.csdn.net/guolin_blog/article/details/9991569 373 | 374 | http://droidyue.com/blog/2015/11/08/make-use-of-handlerthread/ 375 | 376 | 从Android中Thread(java.lang.Thread -> java.lang.Object)描述可以看出,Android的Thread没有对Java的Thread做任何封装,但是Android提供了一个继承自Thread的类HandlerThread(android.os.HandlerThread -> java.lang.Thread),这个类对Java的Thread做了很多便利Android系统的封装。 377 | 378 | android.os.Handler可以通过Looper对象实例化,并运行于另外的线程中,Android提供了让Handler运行于其它线程的线程实现,也是就HandlerThread。HandlerThread对象start后可以获得其Looper对象,并且使用这个Looper对象实例Handler。 379 | 380 | **7.低版本SDK实现高版本api**(小米) 381 | 382 | 自己实现或@TargetApi annotation 383 | 384 | **8.Ubuntu编译安卓系统**(百度) 385 | 386 | 1. 进入源码根目录 387 | 2. . build/envsetup.sh 388 | 3. lunch 389 | 4. full(编译全部) 390 | 5. userdebug(选择编译版本) 391 | 6. make -j8(开启8个线程编译) 392 | 393 | **9.launch mode应用场景**(百度、小米、乐视) 394 | 395 | standard,创建一个新的Activity。 396 | 397 | singleTop,栈顶不是该类型的Activity,创建一个新的Activity。否则,onNewIntent。 398 | 399 | singleTask,回退栈中没有该类型的Activity,创建Activity,否则,onNewIntent+ClearTop。 400 | 401 | 注意: 402 | 403 | 1. 设置了"singleTask"启动模式的Activity,它在启动的时候,会先在系统中查找属性值affinity等于它的属性值taskAffinity的Task存在; 如果存在这样的Task,它就会在这个Task中启动,否则就会在新的任务栈中启动。因此, 如果我们想要设置了"singleTask"启动模式的Activity在新的任务中启动,就要为它设置一个独立的taskAffinity属性值。 404 | 2. 如果设置了"singleTask"启动模式的Activity不是在新的任务中启动时,它会在已有的任务中查看是否已经存在相应的Activity实例, 如果存在,就会把位于这个Activity实例上面的Activity全部结束掉,即最终这个Activity 实例会位于任务的Stack顶端中。 405 | 3. 在一个任务栈中只有一个”singleTask”启动模式的Activity存在。他的上面可以有其他的Activity。这点与singleInstance是有区别的。 406 | 407 | singleInstance,回退栈中,只有这一个Activity,没有其他Activity。 408 | 409 | singleTop适合接收通知启动的内容显示页面。 410 | 411 | 例如,某个新闻客户端的新闻内容页面,如果收到10个新闻推送,每次都打开一个新闻内容页面是很烦人的。 412 | 413 | singleTask适合作为程序入口点。 414 | 415 | 例如浏览器的主界面。不管从多少个应用启动浏览器,只会启动主界面一次,其余情况都会走onNewIntent,并且会清空主界面上面的其他页面。 416 | 417 | singleInstance应用场景: 418 | 419 | 闹铃的响铃界面。 你以前设置了一个闹铃:上午6点。在上午5点58分,你启动了闹铃设置界面,并按 Home 键回桌面;在上午5点59分时,你在微信和朋友聊天;在6点时,闹铃响了,并且弹出了一个对话框形式的 Activity(名为 AlarmAlertActivity) 提示你到6点了(这个 Activity 就是以 SingleInstance 加载模式打开的),你按返回键,回到的是微信的聊天界面,这是因为 AlarmAlertActivity 所在的 Task 的栈只有他一个元素, 因此退出之后这个 Task 的栈空了。如果是以 SingleTask 打开 AlarmAlertActivity,那么当闹铃响了的时候,按返回键应该进入闹铃设置界面。 420 | 421 | **10.touch 事件传递流程**(小米) 422 | 423 | http://hanhailong.com/2015/09/24/Android-%E4%B8%89%E5%BC%A0%E5%9B%BE%E6%90%9E%E5%AE%9ATouch%E4%BA%8B%E4%BB%B6%E4%BC%A0%E9%80%92%E6%9C%BA%E5%88%B6/ 424 | 425 | **11.view绘制流程**(百度) 426 | 427 | http://www.codekk.com/blogs/detail/54cfab086c4761e5001b253f 428 | 429 | **12.多线程**(360) 430 | 431 | * Activity.runOnUiThread(Runnable) 432 | * View.post(Runnable),View.postDelay(Runnable,long) 433 | * Handler 434 | * AsyncTask 435 | 436 | **13.线程同步**(百度) 437 | 438 | http://www.itzhai.com/java-based-notebook-thread-synchronization-problem-solving-synchronization-problems-synchronized-block-synchronized-methods.html#read-more 439 | 440 | http://www.juwends.com/tech/android/android-inter-thread-comm.html 441 | 442 | 单例 443 | 444 | ``` 445 | public class Singleton{ 446 | private volatile static Singleton mSingleton; 447 | private Singleton(){ 448 | } 449 | public static Singleton getInstance(){ 450 | if(mSingleton == null){\\A 451 | synchronized(Singleton.class){\\C 452 | if(mSingleton == null) 453 | mSingleton = new Singleton();\\B 454 | } 455 | } 456 | return mSingleton; 457 | } 458 | } 459 | ``` 460 | **14.什么情况导致内存泄漏**(美团) 461 | 462 | 1.资源对象没关闭造成的内存泄漏 463 | 464 | 描述: 465 | 资源性对象比如(Cursor,File文件等)往往都用了一些缓冲,我们在不使用的时候,应该及时关闭它们,以便它们的缓冲及时回收内存。它们的缓冲不仅存在于 java虚拟机内,还存在于java虚拟机外。如果我们仅仅是把它的引用设置为null,而不关闭它们,往往会造成内存泄漏。因为有些资源性对象,比如 SQLiteCursor(在析构函数finalize(),如果我们没有关闭它,它自己会调close()关闭),如果我们没有关闭它,系统在回收它时也会关闭它,但是这样的效率太低了。因此对于资源性对象在不使用的时候,应该调用它的close()函数,将其关闭掉,然后才置为null.在我们的程序退出时一定要确保我们的资源性对象已经关闭。 466 | 程序中经常会进行查询数据库的操作,但是经常会有使用完毕Cursor后没有关闭的情况。如果我们的查询结果集比较小,对内存的消耗不容易被发现,只有在常时间大量操作的情况下才会复现内存问题,这样就会给以后的测试和问题排查带来困难和风险。 467 | 468 | 2.构造Adapter时,没有使用缓存的convertView 469 | 470 | 描述: 471 | 以构造ListView的BaseAdapter为例,在BaseAdapter中提供了方法: 472 | public View getView(int position, ViewconvertView, ViewGroup parent) 473 | 来向ListView提供每一个item所需要的view对象。初始时ListView会从BaseAdapter中根据当前的屏幕布局实例化一定数量的 view对象,同时ListView会将这些view对象缓存起来。当向上滚动ListView时,原先位于最上面的list item的view对象会被回收,然后被用来构造新出现的最下面的list item。这个构造过程就是由getView()方法完成的,getView()的第二个形参View convertView就是被缓存起来的list item的view对象(初始化时缓存中没有view对象则convertView是null)。由此可以看出,如果我们不去使用 convertView,而是每次都在getView()中重新实例化一个View对象的话,即浪费资源也浪费时间,也会使得内存占用越来越大。 ListView回收list item的view对象的过程可以查看: 474 | android.widget.AbsListView.java --> voidaddScrapView(View scrap) 方法。 475 | 示例代码: 476 | 477 | ``` 478 | public View getView(int position, ViewconvertView, ViewGroup parent) { 479 | View view = new Xxx(...);  480 | ... ...  481 | return view;  482 | }  483 | ``` 484 | 485 | 修正示例代码: 486 | 487 | ``` 488 | public View getView(int position, ViewconvertView, ViewGroup parent) { 489 | View view = null;  490 | if (convertView != null) {  491 | view = convertView;  492 | populate(view, getItem(position));  493 | ...  494 | } else {  495 | view = new Xxx(...);  496 | ...  497 | }  498 | return view;  499 | }  500 | ``` 501 | 502 | 3.Bitmap对象不在使用时调用recycle()释放内存 503 | 504 | 描述: 505 | 有时我们会手工的操作Bitmap对象,如果一个Bitmap对象比较占内存,当它不在被使用的时候,可以调用Bitmap.recycle()方法回收此对象的像素所占用的内存,但这不是必须的,视情况而定。可以看一下代码中的注释: 506 | 507 | /**  508 | •Free up the memory associated with thisbitmap's pixels, and mark the  509 | •bitmap as "dead", meaning itwill throw an exception if getPixels() or  510 | •setPixels() is called, and will drawnothing. This operation cannot be  511 | •reversed, so it should only be called ifyou are sure there are no  512 | •further uses for the bitmap. This is anadvanced call, and normally need  513 | •not be called, since the normal GCprocess will free up this memory when  514 | •there are no more references to thisbitmap.  515 | */  516 | 517 | 4.试着使用关于application的context来替代和activity相关的context 518 | 519 | 这是一个很隐晦的内存泄漏的情况。有一种简单的方法来避免context相关的内存泄漏。最显著地一个是避免context逃出他自己的范围之外。使用Application context。这个context的生存周期和你的应用的生存周期一样长,而不是取决于activity的生存周期。如果你想保持一个长期生存的对象,并且这个对象需要一个context,记得使用application对象。你可以通过调用 Context.getApplicationContext() or Activity.getApplication()来获得。更多的请看这篇文章如何避免 520 | Android内存泄漏。 521 | 522 | 5.注册没取消造成的内存泄漏 523 | 524 | 一些Android程序可能引用我们的Anroid程序的对象(比如注册机制)。即使我们的Android程序已经结束了,但是别的引用程序仍然还有对我们的Android程序的某个对象的引用,泄漏的内存依然不能被垃圾回收。调用registerReceiver后未调用unregisterReceiver。 525 | 比如:假设我们希望在锁屏界面(LockScreen)中,监听系统中的电话服务以获取一些信息(如信号强度等),则可以在LockScreen中定义一个 PhoneStateListener的对象,同时将它注册到TelephonyManager服务中。对于LockScreen对象,当需要显示锁屏界面的时候就会创建一个LockScreen对象,而当锁屏界面消失的时候LockScreen对象就会被释放掉。 526 | 但是如果在释放 LockScreen对象的时候忘记取消我们之前注册的PhoneStateListener对象,则会导致LockScreen无法被垃圾回收。如果不断的使锁屏界面显示和消失,则最终会由于大量的LockScreen对象没有办法被回收而引起OutOfMemory,使得system_process 进程挂掉。 527 | 虽然有些系统程序,它本身好像是可以自动取消注册的(当然不及时),但是我们还是应该在我们的程序中明确的取消注册,程序结束时应该把所有的注册都取消掉。 528 | 529 | 6.集合中对象没清理造成的内存泄漏 530 | 531 | 我们通常把一些对象的引用加入到了集合中,当我们不需要该对象时,并没有把它的引用从集合中清理掉,这样这个集合就会越来越大。如果这个集合是static的话,那情况就更严重了。 532 | 533 | **15.ANR定位和修正** 534 | 535 | 如果开发机器上出现问题,我们可以通过查看/data/anr/traces.txt即可,最新的ANR信息在最开始部分。 536 | 537 | * 主线程被IO操作(从4.0之后网络IO不允许在主线程中)阻塞。 538 | * 主线程中存在耗时的计算 539 | * 主线程中错误的操作,比如Thread.wait或者Thread.sleep等 540 | Android系统会监控程序的响应状况,一旦出现下面两种情况,则弹出ANR对话框 541 | * 应用在5秒内未响应用户的输入事件(如按键或者触摸) 542 | * BroadcastReceiver未在10秒内完成相关的处理 543 | * Service在特定的时间内无法处理完成 20秒 544 | 545 | * 使用AsyncTask处理耗时IO操作。 546 | * 使用Thread或者HandlerThread时,调用Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND)设置优先级,否则仍然会降低程序响应,因为默认Thread的优先级和主线程相同。 547 | * 使用Handler处理工作线程结果,而不是使用Thread.wait()或者Thread.sleep()来阻塞主线程。 548 | * Activity的onCreate和onResume回调中尽量避免耗时的代码 549 | * BroadcastReceiver中onReceive代码也要尽量减少耗时,建议使用IntentService处理。 550 | 551 | 552 | **16.什么情况导致oom**(乐视、美团) 553 | 554 | http://www.jcodecraeer.com/a/anzhuokaifa/androidkaifa/2015/0920/3478.html 555 | 556 | 1)使用更加轻量的数据结构 557 | 2)Android里面使用Enum 558 | 3)Bitmap对象的内存占用 559 | 4)更大的图片 560 | 5)onDraw方法里面执行对象的创建 561 | 6)StringBuilder 562 | 563 | **17.Android Service与Activity之间通信的几种方式** 564 | 565 | * 通过Binder对象 566 | * 通过broadcast(广播)的形式 567 | 568 | **18.Android各个版本API的区别** 569 | 570 | http://blog.csdn.net/lijun952048910/article/details/7980562 571 | 572 | **19. Android代码中实现WAP方式联网**(360) 573 | 574 | http://blog.csdn.net/asce1885/article/details/7844159 575 | 576 | **20.如何保证service在后台不被kill** 577 | 578 | 一、onStartCommand方法,返回START_STICKY 579 | 580 | 1. START_STICKY 581 | 在运行onStartCommand后service进程被kill后,那将保留在开始状态,但是不保留那些传入的intent。不久后service就会再次尝试重新创建,因为保留在开始状态,在创建     service后将保证调用onstartCommand。如果没有传递任何开始命令给service,那将获取到null的intent。 582 | 583 | 2. START_NOT_STICKY 584 | 在运行onStartCommand后service进程被kill后,并且没有新的intent传递给它。Service将移出开始状态,并且直到新的明显的方法(startService)调用才重新创建。因为如果没有传递任何未决定的intent那么service是不会启动,也就是期间onstartCommand不会接收到任何null的intent。 585 | 586 | 3. START_REDELIVER_INTENT 587 | 在运行onStartCommand后service进程被kill后,系统将会再次启动service,并传入最后一个intent给onstartCommand。直到调用stopSelf(int)才停止传递intent。如果在被kill后还有未处理好的intent,那被kill后服务还是会自动启动。因此onstartCommand不会接收到任何null的intent。 588 | 589 | 二、提升service优先级 590 | 591 | 在AndroidManifest.xml文件中对于intent-filter可以通过android:priority = "1000"这个属性设置最高优先级,1000是最高值,如果数字越小则优先级越低,同时适用于广播。 592 | 593 | 三、提升service进程优先级 594 | 595 | Android中的进程是托管的,当系统进程空间紧张的时候,会依照优先级自动进行进程的回收。Android将进程分为6个等级,它们按优先级顺序由高到低依次是: 596 | 597 | 1. 前台进程( FOREGROUND_APP) 598 | 2. 可视进程(VISIBLE_APP ) 599 | 3. 次要服务进程(SECONDARY_SERVER ) 600 | 4. 后台进程 (HIDDEN_APP) 601 | 5. 内容供应节点(CONTENT_PROVIDER) 602 | 6. 空进程(EMPTY_APP) 603 | 604 | 当service运行在低内存的环境时,将会kill掉一些存在的进程。因此进程的优先级将会很重要,可以使用startForeground 将service放到前台状态。这样在低内存时被kill的几率会低一些。 605 | 606 | 四、onDestroy方法里重启service 607 | 608 | service +broadcast  方式,就是当service走ondestory的时候,发送一个自定义的广播,当收到广播的时候,重新启动service; 609 | 610 | 五、Application加上Persistent属性 611 | 612 | 六、监听系统广播判断Service状态 613 | 614 | 通过系统的一些广播,比如:手机重启、界面唤醒、应用状态改变等等监听并捕获到,然后判断我们的Service是否还存活,别忘记加权限啊。 615 | 616 | **21.Requestlayout,onlayout,onDraw,DrawChild区别与联系**(猎豹) 617 | 618 | requestLayout()方法 :会导致调用measure()过程 和 layout()过程 。 619 | 说明:只是对View树重新布局layout过程包括measure()和layout()过程,不会调用draw()过程,但不会重新绘制 620 | 任何视图包括该调用者本身。 621 | 622 | onLayout()方法(如果该View是ViewGroup对象,需要实现该方法,对每个子视图进行布局) 623 | 624 | 调用onDraw()方法绘制视图本身   (每个View都需要重载该方法,ViewGroup不需要实现该方法) 625 | 626 | drawChild()去重新回调每个子视图的draw()方法 627 | 628 | **22.invalidate()和postInvalidate() 的区别及使用**(百度) 629 | 630 | http://blog.csdn.net/mars2639/article/details/6650876 631 | 632 | **23.Android动画框架实现原理** 633 | 634 | Animation框架定义了透明度,旋转,缩放和位移几种常见的动画,而且控制的是整个View,实现原理是每次绘制视图时View所在的ViewGroup中的drawChild函数获取该View的Animation的Transformation值,然后调用canvas.concat(transformToApply.getMatrix()),通过矩阵运算完成动画帧,如果动画没有完成,继续调用invalidate()函数,启动下次绘制来驱动动画,动画过程中的帧之间间隙时间是绘制函数所消耗的时间,可能会导致动画消耗比较多的CPU资源,最重要的是,动画改变的只是显示,并不能相应事件。 635 | 636 | **24.Android为每个应用程序分配的内存大小是多少?**(美团) 637 | 638 | android程序内存一般限制在16M,也有的是24M 639 | 640 | **25.Android View刷新机制**(百度、美团) 641 | 642 | 由ViewRoot对象的performTraversals()方法调用draw()方法发起绘制该View树,值得注意的是每次发起绘图时,并不会重新绘制每个View树的视图,而只会重新绘制那些“需要重绘”的视图,View类内部变量包含了一个标志位DRAWN,当该视图需要重绘时,就会为该View添加该标志位。 643 | 644 | 调用流程 : 645 | 646 | mView.draw()开始绘制,draw()方法实现的功能如下: 647 | 648 | 1. 绘制该View的背景 649 | 2. 为显示渐变框做一些准备操作(见5,大多数情况下,不需要改渐变框)           650 | 3. 调用onDraw()方法绘制视图本身   (每个View都需要重载该方法,ViewGroup不需要实现该方法) 651 | 4. 调用dispatchDraw ()方法绘制子视图(如果该View类型不为ViewGroup,即不包含子视图,不需要重载该方法)值得说明的是,ViewGroup类已经为我们重写了dispatchDraw ()的功能实现,应用程序一般不需要重写该方法,但可以重载父类函数实现具体的功能。 652 | 653 | **26.LinearLayout对比RelativeLayout**(百度) 654 | 655 | 1. RelativeLayout会让子View调用2次onMeasure,LinearLayout 在有weight时,也会调用子View2次onMeasure 656 | 2. RelativeLayout的子View如果高度和RelativeLayout不同,则会引发效率问题,当子View很复杂时,这个问题会更加严重。如果可以,尽量使用padding代替margin。 657 | 3. 在不影响层级深度的情况下,使用LinearLayout和FrameLayout而不是RelativeLayout。 658 | 659 | 最后再思考一下文章开头那个矛盾的问题,为什么Google给开发者默认新建了个RelativeLayout,而自己却在DecorView中用了个LinearLayout。因为DecorView的层级深度是已知而且固定的,上面一个标题栏,下面一个内容栏。采用RelativeLayout并不会降低层级深度,所以此时在根节点上用LinearLayout是效率最高的。而之所以给开发者默认新建了个RelativeLayout是希望开发者能采用尽量少的View层级来表达布局以实现性能最优,因为复杂的View嵌套对性能的影响会更大一些。 660 | 661 | **27.优化自定义view**(百度、乐视、小米) 662 | 663 | 为了加速你的view,对于频繁调用的方法,需要尽量减少不必要的代码。先从onDraw开始,需要特别注意不应该在这里做内存分配的事情,因为它会导致GC,从而导致卡顿。在初始化或者动画间隙期间做分配内存的动作。不要在动画正在执行的时候做内存分配的事情。 664 | 665 | 你还需要尽可能的减少onDraw被调用的次数,大多数时候导致onDraw都是因为调用了invalidate().因此请尽量减少调用invaildate()的次数。如果可能的话,尽量调用含有4个参数的invalidate()方法而不是没有参数的invalidate()。没有参数的invalidate会强制重绘整个view。 666 | 667 | 另外一个非常耗时的操作是请求layout。任何时候执行requestLayout(),会使得Android UI系统去遍历整个View的层级来计算出每一个view的大小。如果找到有冲突的值,它会需要重新计算好几次。另外需要尽量保持View的层级是扁平化的,这样对提高效率很有帮助。 668 | 669 | 如果你有一个复杂的UI,你应该考虑写一个自定义的ViewGroup来执行他的layout操作。与内置的view不同,自定义的view可以使得程序仅仅测量这一部分,这避免了遍历整个view的层级结构来计算大小。这个PieChart 例子展示了如何继承ViewGroup作为自定义view的一部分。PieChart 有子views,但是它从来不测量它们。而是根据他自身的layout法则,直接设置它们的大小。 670 | 671 | **28.ContentProvider**(乐视) 672 | 673 | http://blog.csdn.net/coder_pig/article/details/47858489 674 | 675 | **29.fragment生命周期** 676 | 677 | ![](https://github.com/JackyAndroid/AndroidInterview-Q-A/blob/master/picture/fragment-life.png) 678 | 679 | **30.volley解析**(美团、乐视) 680 | 681 | http://a.codekk.com/detail/Android/grumoon/Volley%20%E6%BA%90%E7%A0%81%E8%A7%A3%E6%9E%90 682 | 683 | **31.Android Glide源码解析** 684 | 685 | http://www.lightskystreet.com/2015/10/12/glide_source_analysis/ 686 | http://frodoking.github.io/2015/10/10/android-glide/ 687 | 688 | **32.Android 设计模式** 689 | 690 | http://blog.csdn.net/bboyfeiyu/article/details/44563871 691 | 692 | **33.架构设计**(搜狐) 693 | 694 | ![](https://github.com/JackyAndroid/AndroidInterview-Q-A/blob/master/picture/architucture.png) 695 | 696 | http://www.tianmaying.com/tutorial/AndroidMVC 697 | 698 | **34.Android属性动画特性**(乐视、小米) 699 | 700 | 如果你的需求中只需要对View进行移动、缩放、旋转和淡入淡出操作,那么补间动画确实已经足够健全了。但是很显然,这些功能是不足以覆盖所有的场景的,一旦我们的需求超出了移动、缩放、旋转和淡入淡出这四种对View的操作,那么补间动画就不能再帮我们忙了,也就是说它在功能和可扩展方面都有相当大的局限性,那么下面我们就来看看补间动画所不能胜任的场景。 701 | 702 | 注意上面我在介绍补间动画的时候都有使用“对View进行操作”这样的描述,没错,补间动画是只能够作用在View上的。也就是说,我们可以对一个Button、TextView、甚至是LinearLayout、或者其它任何继承自View的组件进行动画操作,但是如果我们想要对一个非View的对象进行动画操作,抱歉,补间动画就帮不上忙了。可能有的朋友会感到不能理解,我怎么会需要对一个非View的对象进行动画操作呢?这里我举一个简单的例子,比如说我们有一个自定义的View,在这个View当中有一个Point对象用于管理坐标,然后在onDraw()方法当中就是根据这个Point对象的坐标值来进行绘制的。也就是说,如果我们可以对Point对象进行动画操作,那么整个自定义View的动画效果就有了。显然,补间动画是不具备这个功能的,这是它的第一个缺陷。 703 | 704 | 然后补间动画还有一个缺陷,就是它只能够实现移动、缩放、旋转和淡入淡出这四种动画操作,那如果我们希望可以对View的背景色进行动态地改变呢?很遗憾,我们只能靠自己去实现了。说白了,之前的补间动画机制就是使用硬编码的方式来完成的,功能限定死就是这些,基本上没有任何扩展性可言。 705 | 706 | 最后,补间动画还有一个致命的缺陷,就是它只是改变了View的显示效果而已,而不会真正去改变View的属性。什么意思呢?比如说,现在屏幕的左上角有一个按钮,然后我们通过补间动画将它移动到了屏幕的右下角,现在你可以去尝试点击一下这个按钮,点击事件是绝对不会触发的,因为实际上这个按钮还是停留在屏幕的左上角,只不过补间动画将这个按钮绘制到了屏幕的右下角而已。 707 | 708 | 709 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ###Welcome to follow me on GitHub or CSDN 2 | 3 | GitHub: https://github.com/JackyAndroid 4 | 5 | CSDN: http://blog.csdn.net/rain_butterfly 6 | 7 | [中文版文档](https://github.com/JackyAndroid/AndroidInterview-Q-A/blob/master/README-CN.md) 8 | 9 | --- 10 | 11 | # AndroidInterview-Q-A 12 | Some of the questions (along with their answers) related to android and java asked in top notch companies. 13 | 14 | ###Java 15 | 16 | **1.Significance of Interface** 17 | 18 | - Specification 19 | - extension 20 | - Callback 21 | 22 | **2.The significance of an abstract class** 23 | 24 | * Provide a common type of its subclasses 25 | * Encapsulation subclasses of duplicate content 26 | * To define abstract methods 27 | 28 | **3.The role of the inner class** 29 | 30 | 1. The inner class can use multiple instances of each instance has its own state information, and information with other peripheral objects are independent of each other. 31 | 2. Outside of a single class, allows multiple inner class to implement the same interface in different ways, or the same class inheritance. 32 | 3. Create inner class object moment does not depend on peripheral class object creation. 33 | 4. Inner classes is not confusing "is - a"relationship, it is an independent entity. 34 | 5. Inner class provides better encapsulation, in addition to the outer class, other class cannot access 35 | 36 | **4.Does static method can be overriden?Why or why not?** 37 | 38 | No we can't override static methods. 39 | 40 | Subclass inherits the parent class, use the same method of static and non-static methods, then non-static methods covered in the parent class method (namely rewriting), the static method of the parent is hidden (if the object is the parent class is called the hidden method), the other a subclass inherits the parent class of the static and non-static methods, as for the method overloading I think it is one of the elements in the same class, can't say what the parent class method and what method in a subclass is the embodiment of the method overloading 41 | 42 | **5.Major sorting algorithims and their implementation in Java.** 43 | 44 | These can be found here in this blog - http://blog.csdn.net/qy1387/article/details/7752973 45 | P.S- If you don't understand chinese then please translate blog to your local language. 46 | 47 | **6.Enumerate the Java collection and inheritance relationships** 48 | 49 | ![](https://github.com/JackyAndroid/AndroidInterview-Q-A/blob/master/picture/collection.png) 50 | 51 | **7.What are the important characteristics of the Java virtual machine?** 52 | 53 | An important feature of the Java language is with platform independence.While using the Java virtual machine is the key to achieve this feature.The general high-level language if you want to run on different platforms, at least needs to be compiled into different object code.And after the introduction of Java virtual machine, the Java language runtime on different platforms do not need to recompile.Java language usage patterns Java virtual machine blocked information related to the specific platform, makes the Java language compiler to generate the Java virtual machine to run the target code (byte code), you can run on multiple platforms without modification.Java virtual machine when performing the bytecode, explain the bytecode into concrete platform machine instruction execution. 54 | 55 | **8.Which object will be rid of garbage collection?** 56 | 57 | The Java garbage collection mechanism is the most basic way is to generational collection.In memory area is divided into different generations, object according to its survival time is saved in the corresponding generation area.The general implementation is divided into three generation: young, old and permanent.Memory allocation is occurred in the young generation.When an object survival time long enough, it will be copied to the older generation.For different generations can use different garbage collection algorithm.Divides the starting point is the generation of application objects to study the survival time of statistical rule.In general, an application of most objects in the survival of the time is very short.Such as the survival of the local variable time is only the execution of the method.Based on this, the young generation garbage collection algorithm can be targeted. 58 | 59 | **9.What is the difference between threads and processes?** 60 | 61 | In short, a program of at least one process, a process of at least one thread.The thread dimension is less than the process of dividing, making high concurrency multithreaded program.In addition, the process is in the process of execution has an independent memory unit, and multiple threads to Shared memory, thus greatly improve the efficiency of the program.Threads in the process of execution and process or is there a difference.Each individual threads run a program entry, order execution sequence and the procedure of exports.But the threads will not be able to independently execute, must depend on application, provide multiple threads execute control by the application.From a logical point of view, a multithreaded significance lies in an application, there are multiple execution part can perform at the same time.But were not operating system with multiple threads as multiple independent applications, to realize the process of scheduling and management, and resource allocation.This is the important distinction between the threads and processes.Process is a certain independent function of the program on a run on one of the data collection activities, resource allocation and scheduling process is the system of an independent unit.Thread is a process of an entity, is the basic unit of the CPU scheduling and dispatching, which is smaller than the process of the basic unit of the can run independently. Thread basically does not own system resources, have only a little in operation of essential resources (such as the program counter, a set of registers and stack), but it can be to belong to a Shared other threads of a process possesses all the resources.A thread can be created and revoke another thread;Between the multiple threads in the same process can execute concurrently.Process and thread main difference is that they are the different ways of operating system resources management.Process has its own address space, a process after the collapse, in protected mode will not affect other processes, and in the process of the thread is just a different execution path.Thread has its own stack and local variables, but no single address space between thread, a thread die die is equal to the whole process, so the multi-process program than in a multithreaded program, but in the process of switching cost resources is bigger, the efficiency is less.But for some requirements and at the same time and again to share some of the variables of concurrent operation, can only use threads, cannot use process.If you are interested in further, I suggest you look at the modern operating systems or the design and implementation of the operating system.Said to is a problem more clearly. 62 | 63 | **10.In Java = = and equals the difference, the difference between equals and hashCode** 64 | 65 | http://blog.csdn.net/tiantiandjava/article/details/46988461 66 | 67 | **11.What are the time complexities of common sorting algorithms?** 68 | 69 | ![](https://github.com/JackyAndroid/AndroidInterview-Q-A/blob/master/picture/algorithm.png) 70 | 71 | **12.What is a HashMap implementation principle?** 72 | 73 | 1. A HashMap overview: 74 |    HashMap is based on the hash Map interface of asynchronous implementation.This implementation provides all of the optional mapping operations, and allows the use of null values and null keys.Such does not guarantee the order of the map, in particular, it does not guarantee that the constant sequence. 75 | 2. The data structure of a HashMap: 76 | In the Java programming language, the basic structure is two kinds, one is an array, and another is to simulate a pointer (reference), all of the data structure can be used both to construct the basic structure, HashMap is no exception.HashMap is actually a "linked list hash data structure, which is a combination of array and chain table. 77 | 78 | ![](https://github.com/JackyAndroid/AndroidInterview-Q-A/blob/master/picture/hashmap.jpg) 79 | 80 | Can be seen from the diagram above, a HashMap the underlying structure is an array, each item in the array and a linked list.When a new HashMap will initialize an array. 81 | 82 | **13.Define Java state machine.** 83 | 84 | http://www.jdon.com/designpatterns/designpattern_State.htm 85 | 86 | **14.How many bits and bytes does each of short, int, long, char, float, double contains in Java?** 87 | 88 | 1 byte contains 8 bits 89 | 90 | short 16 2 91 | 92 | int 32 4 93 | 94 | long 64 8 95 | 96 | float 32 4 97 | 98 | double 64 8 99 | 100 | char 16 2 101 | 102 | **15.What is the difference between int and an Integer in Java?** 103 | 104 | http://www.cnblogs.com/shenliang123/archive/2011/10/27/2226903.html 105 | 106 | **16.What is the Difference between string, stringbuffer and stringbuilder?** 107 | 108 | String String constants 109 | 110 | StringBuffer A string variable(Thread safe) 111 | 112 | StringBuilder A string variable(Not thread-safe) 113 | 114 | In short, the type String and StringBuffer types of main performance difference is that the String is an immutable object, so in when to change the type String is equal to generate a new String object, then the pointer to a new String object, so often it is best not to change the contents of the String with a String, because every time generated objects will have an effect on system performance, especially when memory without much reference object, the JVM GC will start to work, that is will be a rather slow speed. 115 | 116 | And if it is to use StringBuffer class the result is different, every time the results to StringBuffer object itself, rather than generating new objects, then change the object reference.So in general we recommend StringBuffer, especially a string object changes often.And in some special cases, the String object String concatenation is explained by the JVM became StringBuffer object, so when the String object than StringBuffer object will not be slow, and in particular, in which of the following String objects generated String efficiency is far faster than StringBuffer: 117 | 118 | String S1 = “This is only a” + “ simple” + “ test”; 119 | 120 | StringBuffer Sb = new StringBuilder(“This is only a”).append(“ simple”).append(“ test”); 121 | You will be surprised to find that generated String S1 object speed is too fast, and this time StringBuffer incredibly speed is not dominant.This is a trick of the JVM, in the eyes of the JVM, the 122 |  String S1 = “This is only a” + “ simple” + “test”; In fact is: String S1 = “This is only a simple test”; So, of course, don't need too much time.But everyone here to note is that if you have a String is a String object from another, is not so fast, such as: 123 |   124 | String S2 = “This is only a”; 125 | String S3 = “ simple”; 126 | String S4 = “ test”; 127 | String S1 = S2 +S3 + S4; 128 | 129 | At that time the JVM will behave according to the original way to do it 130 | 131 | In most cases StringBuffer > String 132 | 133 | StringBuffer 134 | 135 | Java. Lang. StringBuffer thread safe variable character sequence.A similar String String buffer, but cannot be modified.Though at any point in time it contains some specific sequences of characters, but through certain method calls can change the length of the sequence and content. 136 | 137 | A string buffer can be safely used in multiple threads.Can be in when necessary to synchronization of these methods, therefore all operations on any particular instance as if in a serial order, the order and method invocations of each thread order. 138 | 139 | Are the major operating on the StringBuffer append and insert method, can override these methods, to accept any type of data.Each method can effectively to the given data into a string, then the string of characters added or inserted into the string in the buffer.These characters of append method will always add it to the end of the buffer;While the insert method add character at the specified point. 140 | 141 | If z refer to a current contents, for example, is "start" string buffer object, then this method calls z.a ppend (" le ") can make the string buffer includes "tackle", while z.i nsert (4, "le") will change the string buffer, to include the "starlet. 142 | 143 | In most cases StringBuilder > StringBuffer 144 | 145 | java.lang.StringBuilder 146 | 147 | Java. Lang. StringBuilder a mutable sequence of characters is the new 5.0.This provides an API compatible with StringBuffer, but does not guarantee that synchronization.This class is designed to be used as a replacement of a simple StringBuffer, when used in string buffer is used by a single thread (this is very common).If possible, it is recommended that the priority use this class, because in most implementations, it is faster than StringBuffer.Both methods are basically the same 148 | 149 | **17.Explain polymorphism in Java** 150 | 151 | The understanding of Java polymorphism 152 | 153 | Java realization of polymorphism 154 | 155 | What is a polymorphic 156 | 157 | Object-oriented three features: encapsulation, inheritance and polymorphism.From a certain perspective, encapsulation and inheritance are almost for state.This is our last a concept, which is the most important knowledge points. 158 | 159 | The definition of polymorphism refers to allow different kinds of objects to respond to the same news.The same message can be according to difference of sending objects and use a variety of different ways of behavior.(send a message is a function call) 160 | 161 | Polymorphism of the technology, called: dynamic binding (dynamic binding), refers to judgment during the execution of the actual type of reference objects, according to its actual type call the corresponding method. 162 | 163 | The role of polymorphism: eliminate the coupling relationship between the types. 164 | 165 | In reality, examples of polymorphism.If press the F1 key action, for example, the current in the pop-up Flash screen is AS 3 help documentation;If the current pop-up is Word help under the Word;Under the Windows is a pop-up Windows help and support.The same event will produce different results in different objects. 166 | 167 | Here are three necessary conditions for the existence of polymorphism 168 | 169 | Three necessary conditions for the existence of polymorphism 170 | 一、inherited; 171 | 二、rewrite; 172 | 三、The parent class reference is to subclass object。 173 | 174 | Benifits of Polymorphism: 175 | 176 | 1.Replaceability (substitutability).Polymorphism with replaceability to existing code.Polymorphism of Circle Circle kind of work, for example, to any other Circle geometry, such as Circle, also work. 177 | 178 | 2.Scalability (extensibility).Polymorphism has scalability to the code.Add new subclass does not affect existing class polymorphism, inheritance, and other characteristics of run and operation.New subclasses are more likely to actually get polymorphic function.For example, in the realization of the cone, cone and half sphere of polymorphism, it is easy to add ball class polymorphism. 179 | 180 | 3.Interface (interface - ability).Polymorphism is the superclass method signature by to subclass provides a common interface, by subclasses to refine or cover it.As shown in figure 8.3.The Shape CSL class defines two implementations of polymorphic interface methods, computeArea () and computeVolume ().Subclasses, such as Circle and Sphere in order to achieve the polymorphism, perfect or covering the two interface methods. 181 | 182 | 4.Flexibility (flexibility).It embodies the operation of flexible in application, improve the efficiency. 183 | 184 | 5.Simplify (simplicity).Polymorphic simplify the coding of application software and modification process, especially in dealing with a large number of operation and operation of the object, this feature is particularly prominent and important. 185 | 186 | Java realization of polymorphic methods: interface implementation, rewrite the inheritance of the parent class method, in the same class method overloading. 187 | 188 | **18.What causes thread block?** 189 | 190 | The blocking of the thread 191 | 192 | In order to solve the conflict of access to the Shared storage area, Java synchronization mechanism was introduced, now let's examine multiple threads access to Shared resources, synchronization mechanism has obviously not enough, because the resources required at any time may not ready to be accessed, in turn, the same time ready resources can be more than one.In order to solve the problem of this kind of access control, Java's support for blocking mechanism is introduced. 193 | 194 | Blocking refers to suspend the execution of a thread to wait for a condition (such as a resource in place), studied the operating system's classmate of it must have been very familiar with.Java provides a number of ways to support block, let's analyze them one by one. 195 | 196 | 1. Sleep () methods: sleep () allows you to specify a period of time in milliseconds as a parameter, it makes the thread into the blocked state within a specified time, can't get the CPU time, the specified time, the thread back into the executable.Typically, the sleep () is used in waiting for a resource ready: test found that when conditions are not fulfilled, the thread block after a period of time to test, until a condition is met. 197 | 2. Suspend () and resume () method: two methods, suspend () makes the thread into the blocking state, and does not automatically restore, must have its corresponding resume () is called, to make the thread back into the executable.Typically, suspend () and resume () is used in waiting for the result of a another thread: after tests found that the result has not produced, let the thread block, another thread produced results, calls resume () to make it recover. 198 | 3. Yield () method: the yield () allows a thread to abandon the current share of CPU time, but don't make the thread block, the thread is still in the executable state, could share of CPU time again at any time.Call the yield () is equivalent to the effect of the scheduler that the thread has been carried out enough time to go to another thread. 199 | 4. Wait () and notify () method: two methods are used, wait () makes the thread into the blocking state, it has two forms, one allows you to specify a period of time in milliseconds as a parameter, another has no parameters, the former when the corresponding notify () is invoked or beyond the specified time back into the executable thread state, the latter must correspond to the notify () is invoked. 200 | 201 | At first glance they and suspend () and resume () method is no different, but in fact they are very different.The core difference is that in front of the narrative method of all blocked will not release takes lock (if takes up), and the opposite each other. 202 | 203 | The core difference between led to a series of the difference on the details. 204 | 205 | First of all, in front of the narrative of all methods belongs to the Thread class, but the pair of directly affiliated to the Object class, that is to say, all objects with the two methods.At first glance it is quite incredible, but in fact it is very natural, because it blocked a method to release takes up the lock, the lock is any object, invoke arbitrary objects of wait () method of thread blocks, and the lock of the object is released.Object and calling any notify () method to call on the object of the wait () method and random selection in the blocked thread a unblocked (but have to wait until after the lock truly executable). 206 | 207 | Second, the narrative of all method calls can be in any position, but the two methods must be in a synchronized method or block calls, reason is very simple, only in a synchronized method or block the current thread holds locks, lock can be released.In the same way, call this method on the object lock must be owned by the current thread, so you can release a lock.As a result, the pair of method calls must be placed in such a synchronized method or block, the method or block the locked object is to call this method.If they do not meet the conditions, the program, though still able to compile, but abnormal IllegalMonitorStateException at run time. 208 | 209 | Wait () and notify () method of the above features determines they often use, together with a synchronized method or block them and inter-process communication mechanism of the operating system you will find a comparison of their similarities: a synchronized method or block provides a similar to the function of the operating system primitives, their execution will not be multi-threaded mechanism of the interference, and the laws of the other party is equal to the block and wakeup primitives (the two methods are declared as synchronized).They allow us to realize the combination of the operating system on a series of subtle interprocess communication algorithm (e.g., semaphore algorithm), and is used to solve the problem of all kinds of complex communication between threads. 210 | 211 | About the wait () and notify () method and then two points: 212 | 213 | First: call notify () method to remove blocked thread from object by calling the wait () method and random in blocked thread, we cannot predict which thread will be selected, so to be very careful when programming, to avoid the problem due to the uncertainty. 214 | 215 | Second: in addition to notify (), and a method of notifyAll () can also play a similar role, the only difference is that the notifyAll () method will turn the object by call wait () method and block all the threads of disposable is unblocked.Of course, only get a lock that a thread can enter the executable. 216 | 217 | When it comes to block, that is to talk about a deadlock, slightly analysis can be found that suspend () method and do not specify a timeout period of wait () method calls are likely to produce a deadlock.Unfortunately, the Java does not support in the language level to avoid deadlock, we must be careful to avoid deadlock in the programming. 218 | 219 | Above we implemented in Java thread blocking the various methods for the analysis, we analyzed the wait () and notify () method, because they are the most powerful, use is also the most flexible, but it also leads to low efficiency, the more error prone.We should be flexible use of various methods in practical use, in order to better achieve our purpose. 220 | 221 | **19.What is the difference between an abstract class and interface?** 222 | 223 | 1. The realization of the default method 224 | An abstract class can have a default method is completely abstract.The realization of the interface method doesn't exist 225 | 226 | 2. Implementation 227 | Subclasses use the extends keyword to inherit an abstract class.If a subclass isn't an abstract class, it will need to provide all the methods declared in the abstract class.A subclass to implement the interface with the keyword implements.It will need to provide all the methods declared in the interface implementation 228 | 3. The constructor 229 | An abstract class can have a constructor,Interface can not have a constructor 230 | 4. The difference between the interface and the normal Java classes 231 | Besides you cannot instantiate an abstract class, it and ordinary Java classes without any difference 232 | The type of interface is completely different 233 | 234 | 5. Access modifiers 235 | Abstract methods can be public, protected, and the default these modifiers 236 | The default modifier is public interface methods.You can not use other modifiers. 237 | 238 | 6. The main() method 239 | Abstract method can have the main method and we can run it 240 | Interface is not the main method, so we can't afford to run it. 241 | 242 | 7. Multiple inheritance 243 | Abstract classes in the Java language is a kind of inheritance, said in a subclass is only one parent, but there can be multiple interfaces. 244 | 245 | 8. Speed 246 | Abstract class faster than interfaces 247 | Interface is a little slow, because it need time to find the method to realize in the class. 248 | 249 | 9. Add new methods 250 | If you to add a new method in an abstract class, you can give it to the default implementation.So you don't need to change your code now. 251 | If you added to the interface method, then you have to change the class implements the interface. 252 | 253 | **20.What is the difference between container classes?** 254 | 255 | http://www.cnblogs.com/yuanermen/archive/2009/08/05/1539917.html 256 | http://alexyyek.github.io/2015/04/06/Collection/ 257 | http://tianmaying.com/tutorial/java_collection 258 | 259 | **21.Define inner class in Java** 260 | 261 | http://www.cnblogs.com/chenssy/p/3388487.html 262 | 263 | **22.What is HashMap?Differentiate between a HashMap and HashTable in Java.** 264 | 265 | http://www.233.com/ncre2/JAVA/jichu/20100717/084230917.html 266 | 267 | **23.Differentiate between ArrayMap and HashMap** 268 | 269 | http://lvable.com/?p=217 270 | 271 | ###Android 272 | 273 | **1.What types the operation of the database, how to import the external database?** 274 | 275 | The original database is included in the project source res/raw 276 | 277 | Under the android system should be stored in a database/data/data/com. *. * (package name)/directory, so we need to do is to put the existing database into the directory. Operation method is to use FileInputStream read the original database, reoccupy FileOutputStream your read write to that directory. 278 | 279 | **2.Whether used the local radio, and what is the difference between a global broadcast?** 280 | 281 | Because of radio data transmission in the application scope, don't have to worry about privacy data leakage problems. 282 | Don't have to worry about other application forge the broadcast, cause potential safety hazard. 283 | Compared to send global broadcast in the system, it is more efficient. 284 | 285 | **3.Have you used intentService? What is the function of intentService? Does AIDL has solved the problem?** 286 | 287 | To generate a default and independent of each other than the main thread to execute all sent to onStartCommand () method of Intetnt. 288 | 289 | Generate a work queue to send Intent object to your onHandleIntent () method, the same time send an Intent object, only in this way, you don't have to worry about multi-threading.In all request (Intent) was performed after will automatically stop the service, so you shouldn't have to call stopSelf () method to stop. 290 | 291 | The service provides a onBind () method of the default implementation, it returns null 292 | 293 | Provides a onStartCommand () method of the default implementation, it will be the Intent to transfer to the work queue, and then from the work queue every time a transmitted onHandleIntent () method, in the method of Intent on corresponding processing. 294 | 295 | AIDL (Android Interface Definition Language) is a kind of IDL Language, is used to generate on Android devices can be interprocess communication between two processes (interprocess communication, IPC) code.If in a process (such as activities) to invoke another object (e.g., Service) in the process of operation, you can use AIDL 296 | generates serializable parameters. 297 | 298 | AIDL IPC mechanism is an interface, like COM and Corba, but more lightweight.It is to use the proxy class transfer data on the client and implementation. 299 | 300 | **4.What is the difference between an Activity, the Window, and the View? What are some of the characteristics of the fragments?** 301 | 302 | Activity as a craftsman (control unit), the Window like a Window (carrying model), the View like a paper-cut (display View) 303 | 304 | LayoutInflater like scissors, Xml configuration like window drawings. 305 | 306 | 1. Calls to attach in the Activity, to create a Window 307 | 2. Create a window is its subclasses PhoneWindow, create PhoneWindow in the attach 308 | 3. Call in the Activity setContentView(R.layout.xxx) 309 | 4. Which is actually call getWindow().setContentView() 310 | 5. Call of the setContentView PhoneWindow method 311 | 6. Create ParentView
As a subclass of ViewGroup, is actually a DecorView create (as a subclass of FramLayout) 312 | 7. For filling out will specify the R.l ayout. XXX college through the layout filler filler (including the parent means DecorView) 313 | 8. Calls to a ViewGroup 314 | 9. Invoke the ViewGroup removeAllView (), all of the first view to remove 315 | 10. Add a new view: addView () 316 | 317 | Characteristics of fragments 318 | 319 | * Fragments can be used as the Activity of part of the interface 320 | * Can appear many fragments at the same time, in an Activity and a fragments can also be used in more than one Activity 321 | * In the process of Activity operation, can add, remove or replace the fragments 322 | * Fragments can respond to their own input events, and has its own life cycle, their life cycle will be affected by the host of the Activity lifecycle 323 | 324 | **5.Describe a network request process.** 325 | 326 | ![](https://github.com/JackyAndroid/AndroidInterview-Q-A/blob/master/picture/http.png) 327 | 328 | **6.What is the difference between Handler, Thread and HandlerThread?** 329 | 330 | http://blog.csdn.net/guolin_blog/article/details/9991569 331 | 332 | http://droidyue.com/blog/2015/11/08/make-use-of-handlerthread/ 333 | 334 | Thread from the Android (Java. Lang. Thread - > Java. Lang. Object) description can be seen that the Android Thread in Java Thread to do no encapsulation, but Android provides a inheriting from the Thread class HandlerThread (Android. OS. HandlerThread - > Java. Lang, Thread), the class of Java Thread did a lot of convenience Android encapsulation. 335 | 336 | Android. The OS. The Handler can be instantiated by which objects, and running in other threads, android provides for Handler thread running in other threads, is also a HandlerThread.HandlerThread start can be obtained after the stars object, and using this Handler which object instance. 337 | 338 | **7.Low version of the SDK to achieve high version of the API** 339 | 340 | Implement it myself or @ TargetApi annotation 341 | 342 | **8.Ubuntu compiled android** 343 | 344 | 1. Enter the source root directory 345 | 2. . build/envsetup.sh 346 | 3. lunch 347 | 4. full(Compile all) 348 | 5. userdebug(Select compiler version) 349 | 6. make -j8(Open eight compilation thread) 350 | 351 | **9.Describe various launch mode Application scenarios.** 352 | 353 | Standard, create a new Activity. 354 | 355 | SingleTop, stack is not the type of Activity, to create a new Activity.Otherwise, onNewIntent. 356 | 357 | SingleTask, back up the stack without this type of Activity, to create the Activity, otherwise, onNewIntent + ClearTop. 358 | 359 | Note: 360 | 361 | 1. Set the startup mode "singleTask" Activity, when it is launched, affinity will first look for in the system attribute value is equal to the Task that it taskAffinity attribute values exist;If there is such a Task, it will start in this Task, or it will start in the new Task stack.So if we want to set the boot mode "singleTask" Activity start in a new mission, for it set up an independent taskAffinity attribute values. 362 | 2. If set the startup mode "singleTask" Activity is not started in the new task, it will check whether already exists in the existing task corresponding Activity instance, if present, will be put in the end of this Activity instance Activity above all, namely the Activity instance will end up in the task of the top of the Stack. 363 | 3. In a task stack only a "singleTask" startup mode of Activity.He can have other Activity.There is a difference between this and singleInstance. 364 | 365 | SingleInstance, back up the stack, only that an Activity, there is no other Activity. 366 | 367 | SingleTop is suitable for receiving notifications start according to the content of the page. 368 | 369 | For example, a client's news news content page, if you receive 10 news feeds, open a news content page every time, it is very annoying. 370 | 371 | Serve as singleTask program entry point. 372 | 373 | For example, the browser's main interface.No matter how many applications from launch a browser, it will only start the main interface once, the rest will go onNewIntent, and clears the main interface on other pages. 374 | 375 | SingleInstance application scenarios: 376 | 377 | The alarm bell ring interface.You used to set up an alarm: six o 'clock in the morning.58 points at 5 o 'clock in the morning, you start the alarm Settings interface, and press the Home button back to the desktop;At 59 to 5 in the morning, you at WeChat and friend chat;At 6 o 'clock, when the alarm rang, and pop up a dialog box in the form of Activity (called AlarmAlertActivity) prompts you to 6 (this Activity is to SingleInstance loading mode to open), you press the return key, back is WeChat chat interface, this is because the AlarmAlertActivity stack of the Task is only one element, he therefore exit after the Task stack is empty.If is AlarmAlertActivity SingleTask open, so when the alarm is ringing, press the return key should alarm set into the interface. 378 | 379 | **10.Describe Touch event delivery process.** 380 | 381 | http://hanhailong.com/2015/09/24/Android-%E4%B8%89%E5%BC%A0%E5%9B%BE%E6%90%9E%E5%AE%9ATouch%E4%BA%8B%E4%BB%B6%E4%BC%A0%E9%80%92%E6%9C%BA%E5%88%B6/ 382 | 383 | **11.How the view drawing process works?** 384 | 385 | http://www.codekk.com/blogs/detail/54cfab086c4761e5001b253f 386 | 387 | **12.How to use Multithreading in Android?** 388 | 389 | * Activity.runOnUiThread(Runnable) 390 | * View.post(Runnable),View.postDelay(Runnable,long) 391 | * Handler 392 | * AsyncTask 393 | 394 | **13.Describe Thread synchronization process in Android.** 395 | 396 | http://www.itzhai.com/java-based-notebook-thread-synchronization-problem-solving-synchronization-problems-synchronized-block-synchronized-methods.html#read-more 397 | 398 | http://www.juwends.com/tech/android/android-inter-thread-comm.html 399 | 400 | singleton 401 | 402 | ``` 403 | public class Singleton{ 404 | private volatile static Singleton mSingleton; 405 | private Singleton(){ 406 | } 407 | public static Singleton getInstance(){ 408 | if(mSingleton == null){\\A 409 | synchronized(Singleton.class){\\C 410 | if(mSingleton == null) 411 | mSingleton = new Singleton();\\B 412 | } 413 | } 414 | return mSingleton; 415 | } 416 | } 417 | ``` 418 | **14.What are causes of the memory leak?** 419 | 420 | 1. A memory leak caused by resource object is not closed 421 | 422 | Resource objects such as Cursor, File documents, etc.) are often used some buffer, when not in use, we should close them in time, so that their timely recovery of memory buffer.Their buffer not only exists in the Java virtual machine, also exists in the Java virtual closed.If we just put it in the reference set to null, and do not close them, tend to cause a memory leak.Because some resource objects, such as SQLiteCursor (in the destructor finalize (), if we don't close it, it will adjust the close (closed), if we don't close it, system will close it when recycling it, but the efficiency is too low.So for resource object when not in use, should call it the close () function, will close it out, and then set to null. When exiting in our program must ensure that our resource object has been closed.Programs often to query the database operation, but often have completed used without shut down after the Cursor.If our query result set is small, the memory consumption is not easy to find, often the only time a large number of operating case retrieval memory problems, it will bring to screening tests and problems later difficulties and risks. 423 | 424 | 2. Construct the Adapter, without using a cache convertView 425 | 426 | To construct the ListView BaseAdapter, for example, in the BaseAdapter provides methods:Public View getView (int position, ViewconvertView, ViewGroup parent)Give ListView view objects needed for each item.Initial ListView will based on the current screen layout from BaseAdapter instantiate a certain number of view objects, at the same time the ListView will the view object cache.When the scroll up to ListView, originally located at the top of the list item of view objects will be recycled, is then used to construct new appear at the bottom of the list item.The construction process is the getView () method, getView () the second parameter of the View convertView is cached item in the list are of the View object (initialization time the cache does not View objects convertView is null).Thus it can be seen that if we don't use convertView, but each time the getView () to instantiate a View object, namely the waste of resources and waste of time, will also make the memory footprint is more and more big.ListView to recycle the list view object process can view the item:Android. Widget. AbsListView. Java -- > voidaddScrapView (View scrap) method. 427 | 428 | The sample code: 429 | 430 | ``` 431 | public View getView(int position, ViewconvertView, ViewGroup parent) { 432 | View view = new Xxx(...);  433 | ... ...  434 | return view;  435 | }  436 | ``` 437 | 438 | Revised sample code: 439 | 440 | ``` 441 | public View getView(int position, ViewconvertView, ViewGroup parent) { 442 | View view = null;  443 | if (convertView != null) {  444 | view = convertView;  445 | populate(view, getItem(position));  446 | ...  447 | } else {  448 | view = new Xxx(...);  449 | ...  450 | }  451 | return view;  452 | }  453 | ``` 454 | 455 | 3. Bitmap object when not in use call recycle () free memory 456 | 457 | Sometimes we manual operation Bitmap object, if a Bitmap object comparison of memory, when it is not used, can call the Bitmap. The recycle () method to recycle the object pixels of the memory, but it is not necessary, as the case may be.May I see the comments in the code: 458 | 459 | /**  460 | •Free up the memory associated with thisbitmap's pixels, and mark the  461 | •bitmap as "dead", meaning itwill throw an exception if getPixels() or  462 | •setPixels() is called, and will drawnothing. This operation cannot be  463 | •reversed, so it should only be called ifyou are sure there are no  464 | •further uses for the bitmap. This is anadvanced call, and normally need  465 | •not be called, since the normal GCprocess will free up this memory when  466 | •there are no more references to thisbitmap.  467 | */  468 | 469 | 4. Try to use the context of the application to replace the context related to the activity 470 | 471 | This is a very obscure memory leaks.There is a simple way to avoid the context related to the memory leak.The most significant one is to avoid the context to escape from outside the scope of his own.Use the Application context.The context of the life cycle and the application of life cycle, you are long, instead of depending on the activity lifecycle.If you want to keep a long-term survival of object, and this requires a context object, remember to use the application object.You can call the Context. GetApplicationContext () or Activity. GetApplication ().More look at how to avoid this articleAndroid memory leaks. 472 | 473 | 5. Registered didn't cancel cause memory leaks 474 | 475 | Some Android program may refer to our Android objects (such as registration mechanism).Even though our Android program has ended, but the other reference program is still on our Android applications of an object reference, leak memory still cannot be garbage collected.After calling registerReceiver unregisterReceiver did not call.For example, suppose that we want in the lock screen interface (LockScreen), listen to telephone services in order to get some information in the system (such as the signal strength, etc.) can be defined in LockScreen a PhoneStateListener object, register it into the TelephonyManager service at the same time.For LockScreen object, when need to display the lock screen interface can create a LockScreen object, and when the lock screen interface disappeared LockScreen object will be released. 476 | 477 | But if at the time of release LockScreen object forget cancel before we register PhoneStateListener object, leads to LockScreen cannot be garbage collected.If constantly make the lock screen interface display and disappear, will eventually because of a large number of LockScreen object can't be recycled and cause OutOfMemory, make system_process process hang up.Although some system program, it can itself seems to be cancelled automatically registered (not in time, of course), but we should be clear in our programs to cancel the registration, at the end of the program should cancel all registered. 478 | 479 | 6. Collection of objects not clean up the cause of memory leaks 480 | 481 | We usually add some reference to the collection, when we don't need this object, did not make it a reference from the collection, so that this collection will be bigger and bigger.If this set is static, the situation is more serious. 482 | 483 | **15.ANR positioning and correction** 484 | 485 | If development machine appear problem, we can by looking at the/data/anr/traces. TXT, the latest anr information in the first part. 486 | 487 | * The main thread is IO operations (from 4.0 after network IO is not allowed in the main thread) obstruction. 488 | * The main thread of time-consuming calculation 489 | * The wrong operation in the main Thread, such as Thread. Wait or Thread. Sleep, etcThe Android system will monitor the response of the situation, once appear, the following two cases, the pop-up ANR dialog 490 | * Application in 5 seconds did not respond to user input events (such as buttons or touch) 491 | * BroadcastReceiver not complete relevant processing in 10 seconds 492 | * Service in a particular time to handle complete 20 seconds 493 | 494 | * Use AsyncTask processing time consuming IO operations. 495 | * Using Thread or HandlerThread, call Process. SetThreadPriority (Process. THREAD_PRIORITY_BACKGROUND) set priority, or still can reduce response Process, because the default Thread priority is the same as the main Thread. 496 | * Using Handler Thread processing results, rather than using Thread. The wait () or Thread. The sleep () to block the main Thread. 497 | * The Activity's onCreate and onResume avoid time-consuming code in a callback 498 | * The BroadcastReceiver onReceive code also want to minimize the time consuming, it is recommended to use IntentService processing. 499 | 500 | **16.什么情况导致oom** 501 | 502 | http://www.jcodecraeer.com/a/anzhuokaifa/androidkaifa/2015/0920/3478.html 503 | 504 | 1)Use more lightweight data structure 505 | 2)Android use Enum inside 506 | 3)Bitmap object memory footprint 507 | 4)The bigger picture 508 | 5)Ontouch method perform object created inside 509 | 6)StringBuilder 510 | 511 | **17.What are some of modes of communication between Android Service with the Activity?** 512 | 513 | * Through a Binder object 514 | * Through the broadcast in the form of (radio) 515 | 516 | **18.The difference between Android API versions** 517 | 518 | http://blog.csdn.net/lijun952048910/article/details/7980562 519 | 520 | **19. Implementation in the Android WAP way connected to the Internet** 521 | 522 | http://blog.csdn.net/asce1885/article/details/7844159 523 | 524 | **20.How to ensure that the service does not get killed in background?** 525 | 526 | 一、Return to START_STICKY onStartCommand method 527 | 528 | 1. START_STICKY 529 | After running after onStartCommand service process is the kill, it will be held at the beginning, but don't keep the incoming intent.Shortly after the service will try to create again, because in the start state, call onstartCommand will ensure that after creating the service.If not pass any start command to the service, it will get to null intent. 530 | 531 | 2. START_NOT_STICKY 532 | After running after onStartCommand service process is the kill, and there is no new intent passed to it.State of the Service will be removed from the start, and until the new obvious way startService () call to recreate.Because if you don't pass any pending intent so the service is not started, namely during onstartCommand will not receive any null intent. 533 | 534 | 3. START_REDELIVER_INTENT 535 | After running after onStartCommand service process is the kill, system will restart the service, and passed the last intent to onStartCommand.Didn't stop until the call stopSelf (int) passed the intent.If is in after the kill and untreated good intent, the service will start automatically after being the kill.Therefore, onstartCommand will not receive any null intent. 536 | 537 | 二、Improve the service priority 538 | 539 | In AndroidManifest. XML file for intent - can filter through the android: priority = "1000" this attribute sets the highest priority, 1000 is the highest, if the number is smaller, the lower the priority, suitable for broadcast at the same time. 540 | 541 | 三、Improve the service process priority 542 | 543 | Android is managed in the process, when the system process space is tight, will be in accordance with the priority automatically the process of recovery.Android process can be divided into six grades, they in priority order from high to low in turn is: 544 | 545 | 1. Foreground process 546 | 2. The visual process 547 | 3. Secondary service process 548 | 4. Background processes 549 | 5. Content supply nodes 550 | 6. An empty process 551 | 552 | When the service running in low memory conditions, will kill off some existing process.So the process priority will be very important, you can use startForeground put the service in the front desk.When the low memory so kill probability is lower. 553 | 554 | 四、Restart the service in the onDestroy method 555 | 556 | Service + broadcast mode, that is, when the service go ondestory, send a custom broadcast, when the received radio, restart the service; 557 | 558 | 五、Application add Persistent property 559 | 560 | 六、Monitoring system broadcasts to judge the Service state 561 | 562 | Through some broadcasting system, such as: mobile phone restart, interface sensei, application state changes, and so on to monitor and capture, then judge whether our Service also live, don't forget to add permissions. 563 | 564 | **21.Requestlayout onlayout, ontouch, DrawChild differences and relations** 565 | 566 | RequestLayout () method, can lead to call measure () process and layout () process.Description: just back to the View tree layout layout process includes the measure () and layout () procedure, don't call the draw () procedure, but not redrawnAny view including the caller itself. 567 | 568 | OnLayout () method (if the View is ViewGroup object, you need to implement the method, for each child View layout) 569 | 570 | Calling ontouch () method draw View itself (each View to override this method, ViewGroup don't need to implement the method) 571 | 572 | DrawChild () to the callback for each child view the draw () method 573 | 574 | **22.What is the difference between invalidate() and postInvalidate()?** 575 | 576 | http://blog.csdn.net/mars2639/article/details/6650876 577 | 578 | **23.How Android animation framework works?** 579 | 580 | Animation framework defines transparency, rotate, scale and displacement of several common Animation, and control the whole View, the realization principle is every time map View in the View of ViewGroup drawChild function to get the View the Animation of the Transformation of value, and then call canvas. The concat (transformToApply. GetMatrix ()), through the matrix operations complete Animation frames, if there is no complete Animation, continue to call invalidate () function, start the next map to drive the Animation, Animation in the process of clearance between the frame time is consumed by a mapping function, may cause Animation consume more CPU resources, the most important thing is, Animation change just show, and not the corresponding event. 581 | 582 | **24.Android for each application allocated memory size is it?** 583 | 584 | The android program memory is generally limited to 16 m, also have a plenty of 24 m 585 | 586 | **25.Describe View refresh mechanism in Android.** 587 | 588 | Object by ViewRoot performTraversals () method calls the draw () method to draw the tree View, it is worth noting that every time a drawing, does not redraw each View tree View, and will only be redraw those who "need to redraw the View, the View class internal variable contains a sign DRAWN, when the View needs to redraw, will be for the View to add the logo. 589 | 590 | Call the process: 591 | 592 | mView.draw() began to draw,draw() methods the functions as follows: 593 | 594 | 1. Draw the View of the background 595 | 2. Do some preparation for the gradient dialog operation (see 5, in most cases, do not need to change the gradient box)           596 | 3. Calling ontouch () method draw View itself (each View to override this method, ViewGroup don't need to implement the method) 597 | 4. Call dispatchDraw () method draw child views (if the View type of ViewGroup that does not contain child views, do not need to reload the method) is worth, ViewGroup class has been rewritten for us dispatchDraw () function implementation, application generally does not need to rewrite the method, but you can override the parent class function to achieve specific functions. 598 | 599 | **26.LinearLayout contrast RelativeLayout** 600 | 601 | 1. RelativeLayout can let the child View call two onMeasure, LinearLayout in weight, also can call onMeasure View2 times 602 | 2. RelativeLayout child View if different height and RelativeLayout, will lead to efficiency, when the View is very complex, this problem will be more serious.If you can, try to use padding instead of margin. 603 | 3. In does not affect the levels of depth, under the condition of using LinearLayout and FrameLayout rather than RelativeLayout. 604 | 605 | Finally, consider the question of opening the contradiction, why Google to developers default has built a RelativeLayout, in using a LinearLayout DecorView on yourself.Because of the depth of the hierarchy of DecorView is known and fixed, a title bar above, below a NaRongLan.Using RelativeLayout will not reduce the levels of depth, so at this point on the root node using LinearLayout is the most efficient.And the reason for developers default has built a RelativeLayout is a hope that developers can use less as far as possible to express the View hierarchy layout to achieve optimal performance, because the View of complex nested will be a greater impact on performance. 606 | 607 | **27.To optimize the custom view** 608 | 609 | In order to speed up your view, for the method called frequently, need to try to reduce unnecessary code.Begin with ontouch, need special attention should not be here to do the memory allocation, because it will lead to the GC, resulting in caton.During the initialization or animation clearance do allocate memory.Don't do memory allocation when animation is executing. 610 | 611 | You need as far as possible to reduce ontouch is called the number of times, most of the time, cause all ontouch because of call invalidate (). So please try to reduce the call invaildate () the number of times.If possible, try to call contains four parameters invalidate () method rather than no parameters invalidate ().No arguments will invalidate mandatory redraw the entire view. 612 | 613 | Another very time-consuming operation is requested layout.At any time to perform requestLayout (), will make the Android UI system to traverse the entire View hierarchy to calculate the size of each View.If found conflicting values, it will need to recalculate the several times.Also need to try to keep the View hierarchy is flat, it is very helpful to improve efficiency. 614 | 615 | If you have a complex UI, you should consider writing a custom ViewGroup to perform his layout operations.With built-in view is different, the custom view can make the program simply measure the part, this avoids to traverse the entire view hierarchy to calculate the size.The PieChart example shows how to inherit the ViewGroup as part of a custom view.PieChart have child views, but it never measure them.But according to the laws of his own layout, the size of the set them directly. 616 | 617 | **28.What are ContentProviders?** 618 | 619 | http://blog.csdn.net/coder_pig/article/details/47858489 620 | 621 | **29.Life cycle of Fragments.** 622 | 623 | ![](https://github.com/JackyAndroid/AndroidInterview-Q-A/blob/master/picture/fragment-life.png) 624 | 625 | **30.Volley Networking Library.** 626 | 627 | http://a.codekk.com/detail/Android/grumoon/Volley%20%E6%BA%90%E7%A0%81%E8%A7%A3%E6%9E%90 628 | 629 | **31.Glide Library.** 630 | 631 | http://www.lightskystreet.com/2015/10/12/glide_source_analysis/ 632 | http://frodoking.github.io/2015/10/10/android-glide/ 633 | 634 | **32.Design Patterns in Android.** 635 | 636 | http://blog.csdn.net/bboyfeiyu/article/details/44563871 637 | 638 | **33.Architecture design** 639 | 640 | ![](https://github.com/JackyAndroid/AndroidInterview-Q-A/blob/master/picture/architucture.png) 641 | 642 | http://www.tianmaying.com/tutorial/AndroidMVC 643 | 644 | **34.Android attribute animation features** 645 | 646 | If you only need to View in the demand of the mobile, zoom, rotate and fades operation, then fill between animation is enough for the sound.But obviously, these functions is not enough to cover all of the scene, once we demand beyond the mobile, zoom, rotate and fade out of these four, to the operation of the View that filling between the animation will not be able to help us again, that is to say it in terms of function and extensible has considerable limitations, so let's take a look at between animation is not up to the scene. 647 | 648 | Notice above when I fill in the introduction animation has used "to manipulate the View", that's right, curation of animation is only able to function in the View.That is to say, we can on a Button, TextView, even a LinearLayout, or any other inherited from the View of animation component for operation, but if we want to be the object of a non View animation operation, I'm sorry, fill between animation can't help you.Some friends may feel do not understand, how could I need animation on a non View object for operation?Here I cite a simple example, for example we have a custom View, in the View of a Point object is used to manage coordinates, and then in ontouch () method is based on the Point of the object's coordinates to draw.That is to say, if we can to animation operation Point object, so the custom View of animation effects.Obviously, the animation is not have this feature, which is the first of its defects. 649 | 650 | And then fill between animation has a defect, is it can only realize mobile, zoom, rotate and fade out the four kinds of animation, that if we want can be dynamically change the background color of the View?It's a pity that we can only rely on yourself to achieve it.To put it bluntly, before filling mechanism between animation is to use hard-coded way to complete, function is the limited death, basically do not have any extensibility. 651 | 652 | Finally, fill between animation has a fatal flaw, is it just changed the display View, rather than to change the View of the real property.What does that mean?At the upper left of the screen, for instance, now there is a button, and then we through filling between animation to move it to the lower right corner of the screen, now you can go to try to click this button, click event is absolutely not trigger, because in fact this button or stay on the top left corner of the screen, just fill between animation are drawn this button in the lower right corner of the screen. 653 | -------------------------------------------------------------------------------- /picture/algorithm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/droidchef/AndroidInterview-Q-A/945540967f178ba2474272b7a8a1e3fc3cdf009a/picture/algorithm.png -------------------------------------------------------------------------------- /picture/architucture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/droidchef/AndroidInterview-Q-A/945540967f178ba2474272b7a8a1e3fc3cdf009a/picture/architucture.png -------------------------------------------------------------------------------- /picture/collection.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/droidchef/AndroidInterview-Q-A/945540967f178ba2474272b7a8a1e3fc3cdf009a/picture/collection.png -------------------------------------------------------------------------------- /picture/fragment-life.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/droidchef/AndroidInterview-Q-A/945540967f178ba2474272b7a8a1e3fc3cdf009a/picture/fragment-life.png -------------------------------------------------------------------------------- /picture/hashmap.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/droidchef/AndroidInterview-Q-A/945540967f178ba2474272b7a8a1e3fc3cdf009a/picture/hashmap.jpg -------------------------------------------------------------------------------- /picture/http.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/droidchef/AndroidInterview-Q-A/945540967f178ba2474272b7a8a1e3fc3cdf009a/picture/http.png --------------------------------------------------------------------------------