Java基础知识点

面向过程编程和面向对象编程的区别在于:面向过程编程强调的是整个软件系统由一个个函数构成,最小的程序单元是函数,其中作为程序入口的函数称之为主函数,主函数依次调用其他函数,普通函数之间可以相互调用,从而实现整个系统的设计。 面向对象的设计是使所需要的对象具备某些功能,强调的是具备某些功能的对象。面向对象主要有三大特征:封装(Encapsulation),继承(Inheritance),多态(Polymorphism)。

Java运行环境

操作系统(OS)是管理计算机硬件和软件资源的系统软件,为计算机程序提供公共服务。分时操作系统可以有效地使用系统,还可以包括处理器处理器事件、海量存储、打印和其他资源的成本分配的会计软件。对于诸如输入输出和内存分配这样的硬件功能,操作系统充当了程序和计算机硬件之间的中介,尽管应用程序代码通常是由硬件直接执行的,并且常常使系统调用一个OS函数或被它中断。在许多设备上都有操作系统,这些设备包括电脑—-从手机和视频游戏机到网络服务器和超级计算机。Android是一种基于Linux的自由及开发源代码的操作系统。

Android okhttp使用详解

Get 请求

1
2
3
4
5
6
7
Request request = new Request.Builder()
.url(url)
.build();
OkHttpClient client = new OkHttpClient();
try (Response response = client.newCall(request).execute()) {
return response.body().string();
}

通过Request构建请求体,然后由 client 执行。这里 Request 默认请求类型是Get。注意这个是SynchronousGet是同步执行的。在Android UI线程直接运行会报错提示:==android.os.NetworkOnMainThreadException==。

Android使用RenderScript处理图片

RenderScriptAndroid平台上简单快速处理图片效果的脚本工具,Renderscript``基于C99(Ed. C 语言)。使用前需要在Modulebuild.gradle文件中添加两行代码:

1
2
3
4
5
defaultConfig {
//略...
renderscriptTargetApi 24
renderscriptSupportModeEnabled true
}

Android预览pdf文档

谷歌为我们提供了PdfRender工具类对pdf文档进行渲染,首先看一下PdfRender的构造方法:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/**
* Creates a new instance.
* <p>
* <strong>Note:</strong> The provided file descriptor must be <strong>seekable</strong>,
* i.e. its data being randomly accessed, e.g. pointing to a file.
* </p>
* <p>
* <strong>Note:</strong> This class takes ownership of the passed in file descriptor
* and is responsible for closing it when the renderer is closed.
* </p>
* <p>
* If the file is from an untrusted source it is recommended to run the renderer in a separate,
* isolated process with minimal permissions to limit the impact of security exploits.
* </p>
*
* @param input Seekable file descriptor to read from.
*
* @throws java.io.IOException If an error occurs while reading the file.
* @throws java.lang.SecurityException If the file requires a password or
* the security scheme is not supported.
*/
public PdfRenderer(@NonNull ParcelFileDescriptor input){
//略...
}

可以看构造方法中的参数是ParcelFileDescriptor的一个实例,那么ParcelFileDescriptor类是做什么的呢?ParcelFileDescriptor是Android 提供的一种数据结构,支持数据的写入和写出。我们通过ParcelFileDescriptor#open 建立文件和ParcelFileDescriptor的联系

View 事件体系

Android中注解的使用

元注解

@Target:这个注解的取值是一个 ElementType 类型的数组,用来指定注解所使用的对象范围,总共有十种不同的类型,根据定义的注解进行灵活的组合,如下所示:

Hello World

Welcome to Hexo! This is your very first post. Check documentation for more info. If you get any problems when using Hexo, you can find the answer in troubleshooting or you can ask me on GitHub.

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×