每段时间Android开发10个知道(中级系列)-170808

来源:互联网 发布:织梦cms教程视频教程 编辑:程序博客网 时间:2024/06/06 00:18

每段时间Android开发10个知道(中级系列)-170808

由于是中级阶段,所以每次更新的天数间隔会比较长。

1.Android消息机制

http://blog.csdn.net/axi295309066/article/details/60140320?locationNum=2&fps=1

2.Android的线程和线程池

http://blog.csdn.net/laona_sdu/article/details/60468540?locationNum=2&fps=1

3.BitMap的加载和cache

http://blog.csdn.net/zhuxiaoxuand/article/details/51213695?locationNum=6&fps=1

以上3题可得好好研究一番,中级阶段就是揭开Android的神秘面纱,Android消息机制不仅仅停留在Handler了,中级阶段的你应该从它的底层出发,了解起运行机制,Android的线程和线程池,线程自然我也不用多讲其重要性吧!Bitmap的加载和cache,图片的加载就要用到Bitmap,如果你对它不够了解,那么极有可能在使用过程中发生各种异常和错误,比如经常出现”OutOfMemoryError”,这是内存溢出,你在使用过程没及时去回收Bitmap就会出现这种错误,所以我们需要了解Android的cache,从而写出回收Bitmap的方案,不同的情景对应不同的方案,要想克服所有的情景,你需要好好研究Bitmap的原理以及cache的原理,由于Android应用用到图片还是蛮多的,那么Bitmap的使用也是很频繁的,所以它的重要性我就不多说了。

4.Kotlin既然已经成为Android的官方开发语言,那么是不是要好好学学kotlin呢?

http://blog.csdn.net/clandellen/article/details/76369434

http://blog.csdn.net/clandellen/article/details/76519661

http://blog.csdn.net/clandellen/article/details/76602453

后续还会继续更新…….

5.多做做不同的项目,多看看好的项目源码,观摩者必有收获

6.Android当中如何使用注解来绑定控件?

http://blog.csdn.net/qust1508060414/article/details/54729139

7.findViewById()方法绑定控件和注解绑定控件的效率比较

注解用到了反射,自然效率会大大降低,但是比起findViewById来说,方便快捷些。所以什么场景用findViewById,什么场景用注解,要考虑周到。

8.你能写出一个不死亡的线程吗?不是死循环的那种,而是死亡的瞬间,又被重启了

public class RestartThread extends Thread {    private  Thread thread;    public RestartThread(Thread thread){        this.thread = thread;    }    @Override    public void run() {        int times = 0;//记录复活的次数        while(true){            if(!thread.isAlive()){//判断线程是否是非存活状态                 try {                     //利用反射重新构造thread对象                     Class cls = thread.getClass();                     Constructor con = cls.getConstructor();                     con.setAccessible(true);                     Object obj = con.newInstance();                     thread = (Thread) obj;                     if(times==0){                         System.out.println("我开始运行啦!");                         times = 1;                     } else{                         System.out.println("我第"+times+"次复活...");                         times++;                     }                     thread.start();//                } catch (NoSuchMethodException e) {                    e.printStackTrace();                } catch (IllegalAccessException e) {                    e.printStackTrace();                } catch (InstantiationException e) {                    e.printStackTrace();                } catch (InvocationTargetException e) {                    e.printStackTrace();                }            }        }    }    public  static void main(String[] args){        MyThread myThread = new MyThread();        new RestartThread(myThread).start();    }}class MyThread extends  Thread{     public MyThread(){}//为了反射这里必须添加一个空的构造函数,不然就会抛出异常,当然也可以有解决方法,对你而言应该不难    @Override    public void run() {        for(int i=0;i<10;i++){            try {                Thread.sleep(1000);            } catch (InterruptedException e) {                e.printStackTrace();            }            System.out.println(""+i);         }    }}

9.深层次理解Java注解机制

http://blog.csdn.net/chenxiang0207/article/details/8193980

10.Java反射,现在的你必须十分熟悉和掌握

http://blog.csdn.net/briblue/article/details/74616922?locationNum=3&fps=1

阅读全文
5 0