积跬步

Just do IT Now.


  • Home

  • Tags

  • Categories

  • Archives

  • Search

Android面试总结

Posted on 2022-11-01 | In 678
动画类型?属性动画和补间动画的区别?
StringBuffer和StringBuilder区别?
jvm内存模型?
Read more »

AndroidInterview-Q-A

Posted on 2022-11-01 | In 678

AndroidInterview-Q-A

Java

ClassNotFoundException和NoClassDefFoundError的区别

Read more »

从Retrofit的原理来看HTTP

Posted on 2022-08-31 | In Android

Retrofit使用方法简介

  1. 创建一个interface作为Web Service的请求集合,在里面用注解(Annotation)写入需要配置的请求方法

    1
    2
    3
    4
    public interface GitHubService{
    @GET("users/{user}/repos")
    Call<List<Repo>> listRepos(@Path("user") String user);
    }
  2. 在正式代码里用Retrofit创建出interface的实例

    1
    2
    3
    4
    Retrofit retrofit = new Retrofit.Builder()
    .baseUrl("https://api.github.com/")
    .build();
    GitHubService service = retrofit.create(GitHubService.class);
  3. 调用创建出的Service实例的对应方法,创建出相应的可以用来发起网络请求的Call对象

    1
    Call<List<Repo>> repos = service.listRepos("octocat");
  4. 使用Call.execute()或者Call.enqueue()来发起请求

    1
    repos.enqueue(callback);

Retrofit源码结构总结

Read more »

源码-ComponentActivity的LifecycleOwner

Posted on 2022-08-25 | In Android

原文:https://weread.qq.com/web/reader/d82322e0813ab6e2eg015684

起因:使用Dialog未dismiss时Activity关闭了,导致内存泄露
解决:给Dialog添加生命周期监听

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
class TipDialog(context: Context) : Dialog(context), LifecycleObserver {
init {
if (context is ComponentActivity) {
(context as ComponentActivity).lifecycle.addObserver(this)
}
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.item_tip_dialog)
}
@OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
private fun onDestroy() {
if (isShowing) {
dismiss()
}
}
}
Read more »

Gradle配置文件拆解

Posted on 2022-08-15 | In Gradle

Gradle配置文件拆解

gradle配置文件里的内容其实“方法调用”,长得类似与json,其实是groovy中的“闭包”(Closure)知识:把方法当作形参传递进去

java中无法把方法当形参传递,有类似的监听(把方法放进一个类中,用匿名内部类的形式把类的对象传进去)(里面的回调就是延后执行的)【=>闭包内容不一定马上执行】

Read more »

工具-Bean检查

Posted on 2022-07-22 | In Android代码片段

bean检查是否含有非静态内部类

gson对非静态内部类(没有默认构造函数)会有问题

作者提了一种检查方法:运行时去匹配,运行时去拿到model对象的包路径下所有的class对象,然后做规则匹配

Read more »

Java-注解

Posted on 2022-06-10 | In Java

Java 注解(Annotation) | 菜鸟教程 (runoob.com)

Java注解(Annotation)又称Java标注,可以通过反射获取标注内容。在编译器生成类文件时,标注可以被嵌入到字节码中。JVM可以保留标注内容,在运行时可以获取到标注内容。

支持自定义Java标注。

Read more »

优雅写法

Posted on 2022-05-13 | In Android代码片段

工具类

优雅关闭流

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import java.io.Closeable;
import java.io.IOException;

/**
* 说明:关闭流的类
*
* @author shenbh
* time 2021-10-15 15:41
*/
public class CloseableUtil {
public static void close(Closeable closeable){
try {
if (closeable != null){
closeable.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
Read more »

Java-BigDecimal运算

Posted on 2022-03-18 | In Java代码片段

BigDecimal加减乘除计算

  • 加法:add()函数
  • 减法:subtract()函数
  • 乘法:multiply()函数
  • 除法:divide()函数
  • 绝对值:abs()函数
Read more »

工具-网络

Posted on 2022-03-16 | In Android代码片段

Android 使用ping判断网络/WIFI连接是否可用

Read more »

安卓题目-基础面试题

Posted on 2022-03-10 | In 安卓

Android基础面试题(⭐⭐⭐)

什么是 ANR 如何避免它?

答:在 Android 上,如果你的应用程序有一段时间响应不够灵敏,系统会向用户显示一个对话框,这个对话框称作应 用程序无响应(ANR:Application NotResponding)对话框。 用户可以选择让程序继续运行,但是,他们在使用你的 应用程序时,并不希望每次都要处理这个对话框。因此 ,在程序里对响应性能的设计很重要这样,这样系统就不会显 示 ANR 给用户。

Read more »

安卓题目-高级面试题

Posted on 2022-03-10 | In 安卓
Android高级面试题(⭐⭐⭐)
Read more »
<1…678…25>

291 posts
21 categories
47 tags
E-Mail CSDN
0%
© 2018 — 2025 阿炳
Powered by Hexo
|
Theme — NexT.Gemini v5.1.4