diff --git a/android/activity/ch04s11.html b/android/activity/ch04s11.html index bccab3805d..f770924062 100644 --- a/android/activity/ch04s11.html +++ b/android/activity/ch04s11.html @@ -1,6 +1,6 @@ 4.11. Res 资源Home | 简体中文 | 繁体中文 | 杂文 - | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

4.11. Res 资源

+ | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

4.11. Res 资源

4.11.1. 通过名称查找 layout ID

diff --git a/android/board/index.html b/android/board/index.html index e29010fbc3..f3feddcda7 100644 --- a/android/board/index.html +++ b/android/board/index.html @@ -1,10 +1,10 @@ 第 25 章 安卓开发版Home | 简体中文 | 繁体中文 | 杂文 - | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

第 25 章 安卓开发版

+ | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

第 25 章 安卓开发版

-

25.1. rk3568

+

25.1. rk3568

-

25.1.1. 声卡

+

25.1.1. 声卡

 			
diff --git a/android/broadcast/broadcast.static.html b/android/broadcast/broadcast.static.html
index 3260ba7d48..3e50cc818a 100644
--- a/android/broadcast/broadcast.static.html
+++ b/android/broadcast/broadcast.static.html
@@ -98,7 +98,7 @@
 		
 			
-

17.2.2. 接收不到消息

+

17.2.2. 接收不到消息

Android 8 以上,静态广播必须指定包名 intent.setPackage(context.getPackageName());

diff --git a/android/broadcast/index.html b/android/broadcast/index.html
index ae33e52653..3ce8d6a371 100644
--- a/android/broadcast/index.html
+++ b/android/broadcast/index.html
@@ -1,6 +1,6 @@
 
 第 17 章 消息广播Home | 简体中文 | 繁体中文 | 杂文
-		| Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

第 17 章 消息广播

+ | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

第 17 章 消息广播

安卓中有两种广播,一种是系统发出的广播信息,例如网络改变,电池的电量低等等,另一种是用户发出的广播信息。

Android 中的广播类型可以分为两种类型,标准广播和有序广播。

diff --git a/android/camera/ch12s02.html b/android/camera/ch12s02.html index ab2cf1b8d6..478088e975 100644 --- a/android/camera/ch12s02.html +++ b/android/camera/ch12s02.html @@ -1,9 +1,9 @@ 12.2. 相机开发Home | 简体中文 | 繁体中文 | 杂文 - | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

12.2. 相机开发

+ | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

12.2. 相机开发

https://developer.android.google.cn/codelabs/camerax-getting-started?hl=zh-cn#0

-

12.2.1. 页面布局

+

12.2.1. 页面布局

 			
@@ -53,7 +53,7 @@
 			
 			
-

12.2.2. 相机逻辑功能

+

12.2.2. 相机逻辑功能

 			
diff --git a/android/camera/index.html b/android/camera/index.html
index 4aac475a3d..f525971174 100644
--- a/android/camera/index.html
+++ b/android/camera/index.html
@@ -1,8 +1,8 @@
 
 第 12 章 相机与相册Home | 简体中文 | 繁体中文 | 杂文
-		| Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

第 12 章 相机与相册

+ | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

第 12 章 相机与相册

-

12.1. 调用相机

+

12.1. 调用相机

12.1.1. manifest 文件

diff --git a/android/ch27s03.html b/android/ch27s03.html index bc10081552..63fab533e3 100644 --- a/android/ch27s03.html +++ b/android/ch27s03.html @@ -1,6 +1,6 @@ 27.3. java.lang.IllegalStateException: Player is accessed on the wrong thread.Home | 简体中文 | 繁体中文 | 杂文 - | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

27.3. java.lang.IllegalStateException: Player is accessed on the wrong thread.

+ | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

27.3. java.lang.IllegalStateException: Player is accessed on the wrong thread.

 		
diff --git a/android/ch27s04.html b/android/ch27s04.html
index d21cd7059c..d7fd0a587a 100644
--- a/android/ch27s04.html
+++ b/android/ch27s04.html
@@ -1,6 +1,6 @@
 
 27.4. Manifest merger failed with multiple errors, see logsHome | 简体中文 | 繁体中文 | 杂文
-		| Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

27.4. Manifest merger failed with multiple errors, see logs

+ | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

27.4. Manifest merger failed with multiple errors, see logs

通过 gradle processDebugManifest --stacktrace 定位问题

diff --git a/android/ch27s05.html b/android/ch27s05.html
index ee23f100d8..283cc09a47 100644
--- a/android/ch27s05.html
+++ b/android/ch27s05.html
@@ -1,6 +1,6 @@
 
 27.5. android.os.NetworkOnMainThreadExceptionHome | 简体中文 | 繁体中文 | 杂文
-		| Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

27.5. android.os.NetworkOnMainThreadException

+ | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

27.5. android.os.NetworkOnMainThreadException

网络连接会阻塞 UI,必须在线程中异步访问网络

diff --git a/android/ch27s06.html b/android/ch27s06.html
index 9bc0471699..d7b756e28e 100644
--- a/android/ch27s06.html
+++ b/android/ch27s06.html
@@ -1,6 +1,6 @@
 
 27.6. package does not have vibrate permissionHome | 简体中文 | 繁体中文 | 杂文
-		| Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

27.6. package does not have vibrate permission

+ | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

27.6. package does not have vibrate permission

解决方案

diff --git a/android/ch27s07.html b/android/ch27s07.html
index 082b40acde..9f07e20c65 100644
--- a/android/ch27s07.html
+++ b/android/ch27s07.html
@@ -1,6 +1,6 @@
 
 27.7. Can't create handler inside thread Thread[...,5,main] that has not called Looper.prepare()Home | 简体中文 | 繁体中文 | 杂文
-		| Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

27.7. Can't create handler inside thread Thread[...,5,main] that has not called Looper.prepare()

+ | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

27.7. Can't create handler inside thread Thread[...,5,main] that has not called Looper.prepare()

 		
diff --git a/android/ch27s08.html b/android/ch27s08.html
index 60ab353216..5e7fa9e867 100644
--- a/android/ch27s08.html
+++ b/android/ch27s08.html
@@ -1,6 +1,6 @@
 
 27.8. java.lang.SecurityException: Permission denied (missing INTERNET permission?)Home | 简体中文 | 繁体中文 | 杂文
-		| Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

27.8. java.lang.SecurityException: Permission denied (missing INTERNET permission?)

+ | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

27.8. java.lang.SecurityException: Permission denied (missing INTERNET permission?)

 		
diff --git a/android/ch27s09.html b/android/ch27s09.html
index b4f5fb77cd..56ae1012c0 100644
--- a/android/ch27s09.html
+++ b/android/ch27s09.html
@@ -1,6 +1,6 @@
 
 27.9. java.io.IOException: Cleartext HTTP traffic to **** not permittedHome | 简体中文 | 繁体中文 | 杂文
-		| Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

27.9. java.io.IOException: Cleartext HTTP traffic to **** not permitted

+ | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

27.9. java.io.IOException: Cleartext HTTP traffic to **** not permitted

在AndroidManifest.xml配置文件的 application 标签中直接插入

diff --git a/android/ch28.html b/android/ch28.html
index ec7a884f87..5c4c2d4382 100644
--- a/android/ch28.html
+++ b/android/ch28.html
@@ -1,9 +1,9 @@
 
 第 28 章 讯飞云Home | 简体中文 | 繁体中文 | 杂文
-		| Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

第 28 章 讯飞云

+ | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

第 28 章 讯飞云

-

28.1. AIUI

+

28.1. AIUI

 		
@@ -23,7 +23,7 @@
                 mAIUIAgent.sendMessage(aiuiMessage);		
 		
 	
-

28.1.1. AIUIPlayer

+

28.1.1. AIUIPlayer

 		
@@ -342,7 +342,7 @@
 	

28.1.2. 酷我音乐

-

28.1.2.1. 获取音乐URL

+

28.1.2.1. 获取音乐URL

通过 itemId 获取 audio URL

@@ -521,9 +521,9 @@
 		
 		
-

28.1.4. 唤醒词

+

28.1.4. 唤醒词

-

28.1.4.1. 手工唤醒

+

28.1.4.1. 手工唤醒

 			
@@ -532,7 +532,7 @@
 			
-

28.1.5. 汉字转拼音

+

28.1.5. 汉字转拼音

 		
diff --git a/android/ch28s03.html b/android/ch28s03.html
index 36b2aef4cd..61bc716677 100644
--- a/android/ch28s03.html
+++ b/android/ch28s03.html
@@ -1,8 +1,8 @@
 
 28.3. 语音唤醒Home | 简体中文 | 繁体中文 | 杂文
-		| Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

28.3. 语音唤醒

+ | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

28.3. 语音唤醒

-

28.3.1. 范例

+

28.3.1. 范例

diff --git a/android/device/ch03s03.html b/android/device/ch03s03.html
index 3fd61cf53f..f5bc90dd69 100644
--- a/android/device/ch03s03.html
+++ b/android/device/ch03s03.html
@@ -1,6 +1,6 @@
 
 3.3. 设备信息Home | 简体中文 | 繁体中文 | 杂文
-		| Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

3.3. 设备信息

+ | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

3.3. 设备信息

设备 ID

diff --git a/android/device/ch03s04.html b/android/device/ch03s04.html
index 25997bf883..3289fd0a24 100644
--- a/android/device/ch03s04.html
+++ b/android/device/ch03s04.html
@@ -1,6 +1,6 @@
 
 3.4. Physical densityHome | 简体中文 | 繁体中文 | 杂文
-		| Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

3.4. Physical density

+ | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

3.4. Physical density

 		
diff --git a/android/eventbus/EventBus.getingstart.html b/android/eventbus/EventBus.getingstart.html
index 6706c6b964..6cbc1e97fe 100644
--- a/android/eventbus/EventBus.getingstart.html
+++ b/android/eventbus/EventBus.getingstart.html
@@ -27,7 +27,7 @@
 		
 		
-

23.2.1. 创建 MessageEvent 类

+

23.2.1. 创建 MessageEvent 类

 			
@@ -43,7 +43,7 @@
 			
 			
-

23.2.2. Layout

+

23.2.2. Layout

 			
@@ -80,7 +80,7 @@
 			
 			
-

23.2.3. Activity

+

23.2.3. Activity

 			
diff --git a/android/eventbus/StickyEvents.html b/android/eventbus/StickyEvents.html
index e69df5365d..e15d79c9fc 100644
--- a/android/eventbus/StickyEvents.html
+++ b/android/eventbus/StickyEvents.html
@@ -29,7 +29,7 @@
 EventBus.getDefault().unregister( this ) ;	
 		
 		
-

23.3.1. MainActivity

+

23.3.1. MainActivity

Layout

@@ -104,7 +104,7 @@
 			
 			
-

23.3.2. StickyActivity

+

23.3.2. StickyActivity

 			
@@ -159,7 +159,7 @@
 			
 			
-

23.3.3. MessageEvent

+

23.3.3. MessageEvent

 			
diff --git a/android/eventbus/index.html b/android/eventbus/index.html
index 8e4a41ad4f..0eeb50c13a 100644
--- a/android/eventbus/index.html
+++ b/android/eventbus/index.html
@@ -1,6 +1,6 @@
 
 第 23 章 EventBusHome | 简体中文 | 繁体中文 | 杂文
-		| Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

第 23 章 EventBus

+ | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

第 23 章 EventBus

http://greenrobot.org/eventbus diff --git a/android/fragment/ch05s02.html b/android/fragment/ch05s02.html index c176290431..abfdc93ac0 100644 --- a/android/fragment/ch05s02.html +++ b/android/fragment/ch05s02.html @@ -1,6 +1,6 @@ 5.2. 关闭 FragmentHome | 简体中文 | 繁体中文 | 杂文 - | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About

知乎专栏

5.2. 关闭 Fragment

+ | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

5.2. 关闭 Fragment

 		
diff --git a/android/fragment/ch05s03.html b/android/fragment/ch05s03.html
index e53ca0bd56..c80a139aa8 100644
--- a/android/fragment/ch05s03.html
+++ b/android/fragment/ch05s03.html
@@ -1,6 +1,6 @@
 
 5.3. 在 Fragment 中使用 findViewByIdHome | 简体中文 | 繁体中文 | 杂文
-		| Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

5.3. 在 Fragment 中使用 findViewById

+ | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

5.3. 在 Fragment 中使用 findViewById

[提示]提示

使用 getView() 方法返回当前 fragment 的根视图。

diff --git a/android/fragment/ch05s04.html b/android/fragment/ch05s04.html index dc3733e36e..d0ab9a93ec 100644 --- a/android/fragment/ch05s04.html +++ b/android/fragment/ch05s04.html @@ -1,6 +1,6 @@ 5.4. 在 Fragment 中使用 Intent 跳转Home | 简体中文 | 繁体中文 | 杂文 - | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

5.4. 在 Fragment 中使用 Intent 跳转

+ | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

5.4. 在 Fragment 中使用 Intent 跳转

 			
diff --git a/android/fragment/ch05s05.html b/android/fragment/ch05s05.html
index 38f16c9eb2..848992687a 100644
--- a/android/fragment/ch05s05.html
+++ b/android/fragment/ch05s05.html
@@ -1,6 +1,6 @@
 
 5.5. Fragment 中调用 getPackageManager()Home | 简体中文 | 繁体中文 | 杂文
-		| Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

5.5. Fragment 中调用 getPackageManager()

+ | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

5.5. Fragment 中调用 getPackageManager()

 			
diff --git a/android/fragment/ch05s06.html b/android/fragment/ch05s06.html
index db84c3c9e8..e3f95f4049 100644
--- a/android/fragment/ch05s06.html
+++ b/android/fragment/ch05s06.html
@@ -1,6 +1,6 @@
 
 5.6. 在 Fragment 中使用 runOnUiThreadHome | 简体中文 | 繁体中文 | 杂文
-		| Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

5.6. 在 Fragment 中使用 runOnUiThread

+ | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

5.6. 在 Fragment 中使用 runOnUiThread

 			
diff --git a/android/fragment/ch05s07.html b/android/fragment/ch05s07.html
index 38adc72dc8..fc30cc5b9a 100644
--- a/android/fragment/ch05s07.html
+++ b/android/fragment/ch05s07.html
@@ -1,6 +1,6 @@
 
 5.7. Fragment 中调用 findViewByIdHome | 简体中文 | 繁体中文 | 杂文
-		| Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

5.7. Fragment 中调用 findViewById

+ | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

5.7. Fragment 中调用 findViewById

 			
diff --git a/android/fragment/ch05s08.html b/android/fragment/ch05s08.html
index 7cbc86da9d..f760c0cfe6 100644
--- a/android/fragment/ch05s08.html
+++ b/android/fragment/ch05s08.html
@@ -1,6 +1,6 @@
 
 5.8. 替换 FrameLayoutHome | 简体中文 | 繁体中文 | 杂文
-		| Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

5.8. 替换 FrameLayout

+ | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

5.8. 替换 FrameLayout

屏某个区域布局

diff --git a/android/fragment/ch05s09.html b/android/fragment/ch05s09.html
index a2a1584d8d..4f0f45d721 100644
--- a/android/fragment/ch05s09.html
+++ b/android/fragment/ch05s09.html
@@ -1,6 +1,6 @@
 
 5.9. Fragment 接收 BroadcastReceiver 广播Home | 简体中文 | 繁体中文 | 杂文
-		| Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

5.9. Fragment 接收 BroadcastReceiver 广播

+ | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

5.9. Fragment 接收 BroadcastReceiver 广播

定义广播接收类

diff --git a/android/fragment/ch05s10.html b/android/fragment/ch05s10.html
index a0f79fba53..109145bc18 100644
--- a/android/fragment/ch05s10.html
+++ b/android/fragment/ch05s10.html
@@ -1,6 +1,6 @@
 
 5.10. Fragment 加载报错 java.lang.IllegalArgumentException: No view found for id ...Home | 简体中文 | 繁体中文 | 杂文
-		| Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

5.10. Fragment 加载报错 java.lang.IllegalArgumentException: No view found for id ...

+ | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

5.10. Fragment 加载报错 java.lang.IllegalArgumentException: No view found for id ...

 		
diff --git a/android/fragment/ch05s11.html b/android/fragment/ch05s11.html
index 64382c4988..cd13f80f59 100644
--- a/android/fragment/ch05s11.html
+++ b/android/fragment/ch05s11.html
@@ -1,6 +1,6 @@
 
 5.11. 使用 TabLayout 切换 FragmentHome | 简体中文 | 繁体中文 | 杂文
-		| Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

5.11. 使用 TabLayout 切换 Fragment

+ | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

5.11. 使用 TabLayout 切换 Fragment

 		
diff --git a/android/graphics/ch21s02.html b/android/graphics/ch21s02.html
index 55a0990bf1..fce503723f 100644
--- a/android/graphics/ch21s02.html
+++ b/android/graphics/ch21s02.html
@@ -1,6 +1,6 @@
 
 21.2. AnimationDrawableHome | 简体中文 | 繁体中文 | 杂文
-		| Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

21.2. AnimationDrawable

+ | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

21.2. AnimationDrawable

 		
diff --git a/android/graphics/ch21s03.html b/android/graphics/ch21s03.html
index fa2d5fd568..e10f96d525 100644
--- a/android/graphics/ch21s03.html
+++ b/android/graphics/ch21s03.html
@@ -1,6 +1,6 @@
 
 21.3. 矩形Home | 简体中文 | 繁体中文 | 杂文
-		| Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

21.3. 矩形

+ | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

21.3. 矩形

 		
diff --git a/android/graphics/ch21s04.html b/android/graphics/ch21s04.html
index a3801d79e5..254fbe228c 100644
--- a/android/graphics/ch21s04.html
+++ b/android/graphics/ch21s04.html
@@ -1,6 +1,6 @@
 
 21.4. 路径Home | 简体中文 | 繁体中文 | 杂文
-		| Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

21.4. 路径

+ | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

21.4. 路径

下面用 Path 画一个菱形

diff --git a/android/graphics/index.html b/android/graphics/index.html
index bc02b3d230..b4bc315622 100644
--- a/android/graphics/index.html
+++ b/android/graphics/index.html
@@ -1,6 +1,6 @@
 
 第 21 章 图形开发Home | 简体中文 | 繁体中文 | 杂文
-		| Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏
-

21.1.1. Paint.setTextSize() SP to PX

+

21.1.1. Paint.setTextSize() SP to PX

 			
diff --git a/android/index.html b/android/index.html
index 1cd28a0f21..f3a89f3b5a 100644
--- a/android/index.html
+++ b/android/index.html
@@ -20,7 +20,7 @@
 		

电子书最近一次更新于 - 2025-02-24 21:19:58 + 2025-04-04 09:40:40

-

目录

1. 自述
1.1. 写给读者
1.2. 作者简介
1.3. 如何获得文档
1.4. 打赏(Donations)
1.5. 联系方式
1. Android Studio
1.1. 卸载 Android Studio
1.2. 代码格式化
1.3. 设置兼容最低SDK版本
1.4. SDK Tools
1.4.1. 接受 License
1.4.2. 查看 SDK 列表
1.4.3. 按照 Android SDK
1.5. 命令行操作
1.6. adb 命令
1.6.1. 获得 root 权限
1.6.2. 设备管理
1.6.3. Shell
1.6.4. 设备 ID
1.6.5. 查看安卓版本
1.6.6. Logcat
1.6.7. 上传文件
1.6.8. 下载文件
1.6.9. 安卓 .apk bk
1.6.10. 屏幕尺寸
1.6.11. dump 系统信息
1.6.12. 解锁
1.6.13. 蓝牙管理
2. AndroidManifest.xml
2.1. SDK 版本配置
2.2. 开启网络
2.3. 文件存储权限
2.4. 相机权限
2.5. GPS 定位权限
2.6. 全屏-无标题
2.7. 设置为默认开机启动
2.8. 开机启动
2.9. 默认横屏
2.10. 禁止屏幕旋转变化
3. 设备
3.1. 环境变量
3.1.1. 扩展存储
3.1.2. 下载缓存目录
3.1.3. 数据目录
3.2. 配置文件
3.2.1. *.properties 文件
3.2.2. 再 AndroidManifest.xml 使用 meta-data element 定义
3.2.3. 再 build.gradle 文件中配置 productFlavors
3.2.4. 从 assets 目录读取配置文件
3.3. 设备信息
3.4. Physical density
3.5. 声卡
3.5.1. 播放
3.5.2. 录音
3.5.3. 查看声卡信息
3.5.4. /proc/asound 设备信息
3.5.5. 查看声卡当前占用设备
3.5.6. tinymix 设置声卡参数
3.5.7. 麦克风阵列调试
4. Activity
4.1. 界面佈局
4.1.1. setContentView
4.1.2. 隐藏虚拟键
4.1.3. 保持屏幕常开
4.1.4. 标题栏添加返回按钮
4.2. 切换 Activity
4.2.1. startActivity()
4.2.2. App 间跳转
4.2.3. intentActivityResultLauncher 跳转
4.2.4. startActivityForResult 替代方案
4.3. 生命周期
4.3.1. 定时关闭
4.3.2. 恢复触发
4.3.3. 返回触发
4.3.4. Activity 关闭
4.3.5. 重启自己
4.4. Activity 间数据传递
4.4.1. Intent 方式
4.4.2. Bundle 方式
4.4.3. Flag 属性
4.4.4. 返回值
4.5. DataBinding
4.5.1. 启用 DataBinding
4.5.2. MainActivity 中使用 ActivityMainBinding
4.5.3. ViewDataBinding 例子
4.6. 键盘事件
4.6.1. onKeyDown 键盘按下事件
4.6.2. dispatchKeyEvent
4.6.3. 屏蔽 KeyEvent.KEYCODE_BACK
4.6.4. 判断按下次数
4.7. 鼠标事件
4.8. 分享
4.8.1. 分享文本内容
4.8.2. 分享图片
4.8.3.
4.9. 剪切板
4.10. 软键盘控制
4.11. Res 资源
4.11.1. 通过名称查找 layout ID
4.11.2. 查找 drawable 资源 ID
4.11.3. 获取 color 颜色 ID
4.11.4. 获取 array.xml 文件下某个字段的 ID
4.11.5. 获取 style.xml 文件下的某个样式的 id
4.11.6. 主题 themes.xml
5. Fragment
5.1. 启动 Fragment
5.2. 关闭 Fragment
5.3. 在 Fragment 中使用 findViewById
5.4. 在 Fragment 中使用 Intent 跳转
5.5. Fragment 中调用 getPackageManager()
5.6. 在 Fragment 中使用 runOnUiThread
5.7. Fragment 中调用 findViewById
5.8. 替换 FrameLayout
5.9. Fragment 接收 BroadcastReceiver 广播
5.10. Fragment 加载报错 java.lang.IllegalArgumentException: No view found for id ...
5.11. 使用 TabLayout 切换 Fragment
6. Resources
6.1. strings.xml
6.1.1. 字符串
6.1.2. 定义数组
6.1.3. 获取 Resource
6.1.4. Fragment 获取 Resource
6.2. dimens.xml
7. Palette 视觉设计
7.1. 禁止屏幕休眠
7.2. 颜色设置
7.2.1. 颜色设置
7.3. 样式布局
7.3.1. ConstraintLayout
7.3.2. LinearLayout
7.3.3. FrameLayout
7.3.4. 声音波形图
7.4. UI 界面
7.4.1. Toast
7.4.2. Dialog
7.4.3. DatePicker
7.5. Text
7.5.1. Text 相关属性
7.5.2. TextView
7.5.3. EditText
7.5.4. 光标移动到行尾
7.5.5. 禁止选择文本
7.5.6. 设置 app:backgroundTint
7.5.7. 禁止滚动条
7.6. Button
7.6.1. 启用禁用
7.6.2. 实现 OnClickListener 接口
7.6.3. Fragment 中使用 Button
7.6.4. 圆形按钮
7.6.5. ImageButton
7.7. Switch
7.8. Widgets
7.8.1. ImageView
7.8.2. TextClock
7.8.3. 进度条
7.8.4. NestedScrollView +
7.9. Containers
7.9.1. CardView
7.9.2. RecyclerView
7.9.3. NavigationView
7.9.4. 底部导航
7.9.5. TabLayout
7.9.6. ViewPager2
7.9.7. Navigation
7.10. 屏幕
7.10.1. 尺寸
7.10.2. 全屏显示
7.10.3. 屏幕触摸事件 onTouch(View view, MotionEvent motionEvent)
7.10.4. 手势事件
7.10.5. SimpleOnGestureListener
7.10.6. SimpleOnScaleGestureListener
7.11. 带有小三角指示的消息框
7.11.1. 左侧三角
7.11.2. 右侧三角
7.11.3. 正三角
7.11.4. 倒三角
7.11.5. 文本边框
7.11.6. 布局
8. Schedule 计划任务
8.1. 延迟执行
8.2. Time 和 TimerTask 定时刷新
8.3. 使用 Runnable 和 Handler 实现定时执行
8.4. 循环执行
8.5. TimerTask 实现循环播放
8.6. TimerTask 更新 UI
9. Internationalization i18n with Android (国际化)
9.1. 创建国际化文件
9.2. strings.xml 文件
9.3. 翻译语言
9.4. 引用国际化文件
9.5. 切换语言
10. 存储
10.1. 获得存储目录
10.1.1. 公共存储目录
10.1.2. 内部存储
10.1.3. 扩展存储
10.1.4. 文件夹类型
10.2. FileProvider 配置
10.3. SharedPreferences
10.3.1. 操作模式
10.3.2. 保存数据
10.3.3. 读取数据
10.3.4. 通过 key 查询数据是否存在
10.3.5. 删除数据
10.3.6. 清空数据
10.3.7. 对象存储
10.3.8. SharedPreferences 读取物理存储文件
10.4. SD Card
10.4.1. SD Card 状态
10.4.2. Android 11 申请 sdcard 权限
10.5. 下载管理
10.5.1. 从 URL 下来文件
10.5.2. 安装 APK
10.5.3. 下载后接收广播通知
10.6. android.os.FileUriExposedException
11. 网络
11.1. Wifi 配置
11.2. OkHttp - An HTTP & HTTP/2 client for Android and Java +

目录

1. 自述
1.1. 写给读者
1.2. 作者简介
1.3. 如何获得文档
1.4. 打赏(Donations)
1.5. 联系方式
1. Android Studio
1.1. 卸载 Android Studio
1.2. 代码格式化
1.3. 设置兼容最低SDK版本
1.4. SDK Tools
1.4.1. 接受 License
1.4.2. 查看 SDK 列表
1.4.3. 按照 Android SDK
1.5. 命令行操作
1.6. adb 命令
1.6.1. 获得 root 权限
1.6.2. 设备管理
1.6.3. Shell
1.6.4. 设备 ID
1.6.5. 查看安卓版本
1.6.6. Logcat
1.6.7. 上传文件
1.6.8. 下载文件
1.6.9. 安卓 .apk bk
1.6.10. 屏幕尺寸
1.6.11. dump 系统信息
1.6.12. 解锁
1.6.13. 蓝牙管理
2. AndroidManifest.xml
2.1. SDK 版本配置
2.2. 开启网络
2.3. 文件存储权限
2.4. 相机权限
2.5. GPS 定位权限
2.6. 全屏-无标题
2.7. 设置为默认开机启动
2.8. 开机启动
2.9. 默认横屏
2.10. 禁止屏幕旋转变化
3. 设备
3.1. 环境变量
3.1.1. 扩展存储
3.1.2. 下载缓存目录
3.1.3. 数据目录
3.2. 配置文件
3.2.1. *.properties 文件
3.2.2. 再 AndroidManifest.xml 使用 meta-data element 定义
3.2.3. 再 build.gradle 文件中配置 productFlavors
3.2.4. 从 assets 目录读取配置文件
3.3. 设备信息
3.4. Physical density
3.5. 声卡
3.5.1. 播放
3.5.2. 录音
3.5.3. 查看声卡信息
3.5.4. /proc/asound 设备信息
3.5.5. 查看声卡当前占用设备
3.5.6. tinymix 设置声卡参数
3.5.7. 麦克风阵列调试
4. Activity
4.1. 界面佈局
4.1.1. setContentView
4.1.2. 隐藏虚拟键
4.1.3. 保持屏幕常开
4.1.4. 标题栏添加返回按钮
4.2. 切换 Activity
4.2.1. startActivity()
4.2.2. App 间跳转
4.2.3. intentActivityResultLauncher 跳转
4.2.4. startActivityForResult 替代方案
4.3. 生命周期
4.3.1. 定时关闭
4.3.2. 恢复触发
4.3.3. 返回触发
4.3.4. Activity 关闭
4.3.5. 重启自己
4.4. Activity 间数据传递
4.4.1. Intent 方式
4.4.2. Bundle 方式
4.4.3. Flag 属性
4.4.4. 返回值
4.5. DataBinding
4.5.1. 启用 DataBinding
4.5.2. MainActivity 中使用 ActivityMainBinding
4.5.3. ViewDataBinding 例子
4.6. 键盘事件
4.6.1. onKeyDown 键盘按下事件
4.6.2. dispatchKeyEvent
4.6.3. 屏蔽 KeyEvent.KEYCODE_BACK
4.6.4. 判断按下次数
4.7. 鼠标事件
4.8. 分享
4.8.1. 分享文本内容
4.8.2. 分享图片
4.8.3.
4.9. 剪切板
4.10. 软键盘控制
4.11. Res 资源
4.11.1. 通过名称查找 layout ID
4.11.2. 查找 drawable 资源 ID
4.11.3. 获取 color 颜色 ID
4.11.4. 获取 array.xml 文件下某个字段的 ID
4.11.5. 获取 style.xml 文件下的某个样式的 id
4.11.6. 主题 themes.xml
5. Fragment
5.1. 启动 Fragment
5.2. 关闭 Fragment
5.3. 在 Fragment 中使用 findViewById
5.4. 在 Fragment 中使用 Intent 跳转
5.5. Fragment 中调用 getPackageManager()
5.6. 在 Fragment 中使用 runOnUiThread
5.7. Fragment 中调用 findViewById
5.8. 替换 FrameLayout
5.9. Fragment 接收 BroadcastReceiver 广播
5.10. Fragment 加载报错 java.lang.IllegalArgumentException: No view found for id ...
5.11. 使用 TabLayout 切换 Fragment
6. Resources
6.1. strings.xml
6.1.1. 字符串
6.1.2. 定义数组
6.1.3. 获取 Resource
6.1.4. Fragment 获取 Resource
6.2. dimens.xml
7. Palette 视觉设计
7.1. 禁止屏幕休眠
7.2. 颜色设置
7.2.1. 颜色设置
7.3. 样式布局
7.3.1. ConstraintLayout
7.3.2. LinearLayout
7.3.3. FrameLayout
7.3.4. 声音波形图
7.4. UI 界面
7.4.1. Toast
7.4.2. Dialog
7.4.3. DatePicker
7.5. Text
7.5.1. Text 相关属性
7.5.2. TextView
7.5.3. EditText
7.5.4. 光标移动到行尾
7.5.5. 禁止选择文本
7.5.6. 设置 app:backgroundTint
7.5.7. 禁止滚动条
7.6. Button
7.6.1. 启用禁用
7.6.2. 实现 OnClickListener 接口
7.6.3. Fragment 中使用 Button
7.6.4. 圆形按钮
7.6.5. ImageButton
7.7. Switch
7.8. Widgets
7.8.1. ImageView
7.8.2. TextClock
7.8.3. 进度条
7.8.4. NestedScrollView +
7.9. Containers
7.9.1. CardView
7.9.2. RecyclerView
7.9.3. NavigationView
7.9.4. 底部导航
7.9.5. TabLayout
7.9.6. ViewPager2
7.9.7. Navigation
7.10. 屏幕
7.10.1.
7.10.2. 媒体路由
7.10.3. 分辨率
7.10.4. 尺寸
7.10.5. 全屏显示
7.10.6. 音频处理
7.10.7. 屏幕触摸事件 onTouch(View view, MotionEvent motionEvent)
7.10.8. 手势事件
7.10.9. SimpleOnGestureListener
7.10.10. SimpleOnScaleGestureListener
7.11. 带有小三角指示的消息框
7.11.1. 左侧三角
7.11.2. 右侧三角
7.11.3. 正三角
7.11.4. 倒三角
7.11.5. 文本边框
7.11.6. 布局
8. Schedule 计划任务
8.1. 延迟执行
8.2. Time 和 TimerTask 定时刷新
8.3. 使用 Runnable 和 Handler 实现定时执行
8.4. 循环执行
8.5. TimerTask 实现循环播放
8.6. TimerTask 更新 UI
9. Internationalization i18n with Android (国际化)
9.1. 创建国际化文件
9.2. strings.xml 文件
9.3. 翻译语言
9.4. 引用国际化文件
9.5. 切换语言
10. 存储
10.1. 获得存储目录
10.1.1. 公共存储目录
10.1.2. 内部存储
10.1.3. 扩展存储
10.1.4. 文件夹类型
10.2. FileProvider 配置
10.3. SharedPreferences
10.3.1. 操作模式
10.3.2. 保存数据
10.3.3. 读取数据
10.3.4. 通过 key 查询数据是否存在
10.3.5. 删除数据
10.3.6. 清空数据
10.3.7. 对象存储
10.3.8. SharedPreferences 读取物理存储文件
10.4. SD Card
10.4.1. SD Card 状态
10.4.2. Android 11 申请 sdcard 权限
10.5. 下载管理
10.5.1. 从 URL 下来文件
10.5.2. 安装 APK
10.5.3. 下载后接收广播通知
10.6. android.os.FileUriExposedException
11. 网络
11.1. Wifi 配置
11.2. OkHttp - An HTTP & HTTP/2 client for Android and Java applications -
11.2.1. Gradle
11.2.2. AndroidManifest.xml 开启网络访问权限
11.2.3. okhttp 默认是 HTTPS 开启 HTTP
11.2.4. 连接池
11.2.5. GET
11.2.6. POST
11.2.7. HTTP PUT 请求
11.2.8. http header 相关设置
11.2.9. HTTP Base Auth
11.2.10. HttpUrl.Builder 组装 URL 地址参数
11.2.11. Android Activity Example
11.2.12. Android Oauth2 + Jwt example
11.2.13. HTTP/2
11.2.14. 异步更新 UI
11.2.15. SSE 客户端
11.2.16. WebSocket Client
11.2.17. EventListener
12. 相机与相册
12.1. 调用相机
12.1.1. manifest 文件
12.1.2. layout
12.1.3. Activity
12.2. 相机开发
12.2.1. 页面布局
12.2.2. 相机逻辑功能
12.3. LED flash 做手电筒
13. 麦克风与录音
13.1. 开启麦克风和SD卡权限
13.2. layout
13.3. Activity
14. 多媒体开发
14.1. MediaPlayer
14.1.1. 播放Raw下的元数据
14.1.2. 播放assets文件夹中的音乐
14.1.3. 播放互联网音乐
14.1.4. 使用单例模式
14.1.5. 设置速度,快进播放
14.2. VideoView 开发
14.2.1. 播放网络视频
14.2.2. MediaController 添加翻页事件
14.2.3. 静音播放视频
14.2.4. 更新进度条
14.2.5. 完整的例子
14.2.6. 循环播放
14.2.7. 静音播放
14.3. SoundPool
14.4. 音量控制
14.5. SurfaceView
14.6. Vitamio
15. 定位
15.1. GPS + 网络 定位
15.1.1. manifest 权限配置
15.1.2. layout
15.1.3. Activity
15.2. 只从 GPS 获取定位
16. 电话
16.1. SIM 卡状态
16.2. 通信录与拨打电话
16.3. 发送短信
17. 消息广播
17.1. 动态注册
17.2. 静态注册
17.2.1. 电源管理
17.2.2. 接收不到消息
17.3. 自定义用户消息广播
17.4. 本地广播
17.5. 动态监听广播
17.6. 广播重复接收
17.7. 指定静态广播接收者
17.8. 异步执行广播
17.9. 静态广播接收不到信息
18. Service 服务
18.1. Service的基本用法
18.1.1. manifest 文件
18.1.2. 创建 Service
18.1.3. Layout 代码
18.1.4. Activity 代码
18.2. Service 中启动线程
18.3. Service 和 Activity 通信
18.3.1. Layout
18.3.2. Service
18.3.3. Activity
18.4. Service 和 Toast
18.5. Service 中启动 Activity
18.6. Service 中更新 UI
18.7. 前台启动 Service
18.8. 在 Fragment 中启动 Service
19. Notification 通知中心
19.1. 文本通知
19.2. 添加点击操作
19.3. Notification 给 Activity 传值
19.4. 通过 isNotification 判断是否需要执行 onStop() 和 onDestroy()
20. NFC (Near field communication)
20.1. AndroidManifest.xml 文件配置
20.2. Loyout 文件
20.3. Activity 文件
21. 图形开发
21.1. Paint
21.1.1. Paint.setTextSize() SP to PX
21.2. AnimationDrawable
21.3. 矩形
21.4. 路径
22. Android 多线程
22.1. Sleep
22.2. GPIO
22.3. 消息队列
22.3.1. 非阻塞队列 ConcurrentLinkedQueue
23. EventBus
23.1. 添加 EventBus 依赖到项目Gradle文件
23.2. 快速开始一个演示例子
23.2.1. 创建 MessageEvent 类
23.2.2. Layout
23.2.3. Activity
23.3. Sticky Events
23.3.1. MainActivity
23.3.2. StickyActivity
23.3.3. MessageEvent
23.3.4. 删除粘性事件
23.4. 线程模型
23.5. 配置 EventBus
23.6. 事件优先级
23.7. 捕获异常事件
24. Android MQTT
24.1. build.gradle 添加依赖包
24.2. AndroidManifest.xml
24.3. Android Mqtt v5 例子
25. 安卓开发版
25.1. rk3568
25.1.1. 声卡
26. 杂项
26.1. Caused by: java.net.UnknownServiceException: CLEARTEXT +
11.2.1. Gradle
11.2.2. AndroidManifest.xml 开启网络访问权限
11.2.3. okhttp 默认是 HTTPS 开启 HTTP
11.2.4. 连接池
11.2.5. GET
11.2.6. POST
11.2.7. HTTP PUT 请求
11.2.8. http header 相关设置
11.2.9. HTTP Base Auth
11.2.10. HttpUrl.Builder 组装 URL 地址参数
11.2.11. Android Activity Example
11.2.12. Android Oauth2 + Jwt example
11.2.13. HTTP/2
11.2.14. 异步更新 UI
11.2.15. SSE 客户端
11.2.16. WebSocket Client
11.2.17. EventListener
12. 相机与相册
12.1. 调用相机
12.1.1. manifest 文件
12.1.2. layout
12.1.3. Activity
12.2. 相机开发
12.2.1. 页面布局
12.2.2. 相机逻辑功能
12.3. LED flash 做手电筒
13. 麦克风与录音
13.1. 开启麦克风和SD卡权限
13.2. layout
13.3. Activity
14. 多媒体开发
14.1. MediaPlayer
14.1.1. 播放Raw下的元数据
14.1.2. 播放assets文件夹中的音乐
14.1.3. 播放互联网音乐
14.1.4. 使用单例模式
14.1.5. 设置速度,快进播放
14.2. VideoView 开发
14.2.1. 播放网络视频
14.2.2. MediaController 添加翻页事件
14.2.3. 静音播放视频
14.2.4. 更新进度条
14.2.5. 完整的例子
14.2.6. 循环播放
14.2.7. 静音播放
14.3. SoundPool
14.4. 音量控制
14.5. SurfaceView
14.6. Vitamio
15. 定位
15.1. GPS + 网络 定位
15.1.1. manifest 权限配置
15.1.2. layout
15.1.3. Activity
15.2. 只从 GPS 获取定位
16. 电话
16.1. SIM 卡状态
16.2. 通信录与拨打电话
16.3. 发送短信
17. 消息广播
17.1. 动态注册
17.2. 静态注册
17.2.1. 电源管理
17.2.2. 接收不到消息
17.3. 自定义用户消息广播
17.4. 本地广播
17.5. 动态监听广播
17.6. 广播重复接收
17.7. 指定静态广播接收者
17.8. 异步执行广播
17.9. 静态广播接收不到信息
18. Service 服务
18.1. Service的基本用法
18.1.1. manifest 文件
18.1.2. 创建 Service
18.1.3. Layout 代码
18.1.4. Activity 代码
18.2. Service 中启动线程
18.3. Service 和 Activity 通信
18.3.1. Layout
18.3.2. Service
18.3.3. Activity
18.4. Service 和 Toast
18.5. Service 中启动 Activity
18.6. Service 中更新 UI
18.7. 前台启动 Service
18.8. 在 Fragment 中启动 Service
19. Notification 通知中心
19.1. 文本通知
19.2. 添加点击操作
19.3. Notification 给 Activity 传值
19.4. 通过 isNotification 判断是否需要执行 onStop() 和 onDestroy()
20. NFC (Near field communication)
20.1. AndroidManifest.xml 文件配置
20.2. Loyout 文件
20.3. Activity 文件
21. 图形开发
21.1. Paint
21.1.1. Paint.setTextSize() SP to PX
21.2. AnimationDrawable
21.3. 矩形
21.4. 路径
22. Android 多线程
22.1. Sleep
22.2. GPIO
22.3. 消息队列
22.3.1. 非阻塞队列 ConcurrentLinkedQueue
23. EventBus
23.1. 添加 EventBus 依赖到项目Gradle文件
23.2. 快速开始一个演示例子
23.2.1. 创建 MessageEvent 类
23.2.2. Layout
23.2.3. Activity
23.3. Sticky Events
23.3.1. MainActivity
23.3.2. StickyActivity
23.3.3. MessageEvent
23.3.4. 删除粘性事件
23.4. 线程模型
23.5. 配置 EventBus
23.6. 事件优先级
23.7. 捕获异常事件
24. Android MQTT
24.1. build.gradle 添加依赖包
24.2. AndroidManifest.xml
24.3. Android Mqtt v5 例子
25. 安卓开发版
25.1. rk3568
25.1.1. 声卡
26. 杂项
26.1. Caused by: java.net.UnknownServiceException: CLEARTEXT communication to 47.100.253.187 not permitted by network security policy -
26.2. 设计模式
26.2.1. 单例模式
26.3. Android OS 包
26.3.1. 进程ID
26.3.2. handler
26.4. fastjson android
26.4.1. 对象转字符串
26.4.2. JsonObject 转对象
26.4.3. 字符串 与 json 互转
26.4.4. json 转 数组
26.4.5. JSON数组转List
26.4.6. Map 与 Json 互转
26.5. Butter Knife
26.6. Android Things
26.6.1. GPIO
27. FAQ
27.1. java.net.UnknownServiceException: CLEARTEXT communication to 192.168.0.185 not permitted by network security policy
27.2. Caused by: android.os.NetworkOnMainThreadException
27.3. java.lang.IllegalStateException: Player is accessed on the wrong thread.
27.4. Manifest merger failed with multiple errors, see logs
27.5. android.os.NetworkOnMainThreadException
27.6. package does not have vibrate permission
27.7. Can't create handler inside thread Thread[...,5,main] that has not called Looper.prepare()
27.8. java.lang.SecurityException: Permission denied (missing INTERNET permission?)
27.9. java.io.IOException: Cleartext HTTP traffic to **** not permitted
28. 讯飞云
28.1. AIUI
28.1.1. AIUIPlayer
28.1.2. 酷我音乐
28.1.3. 控制技能
28.1.4. 唤醒词
28.1.5. 汉字转拼音
28.2. 讯飞 TTS
28.2.1. 设置日志输出级别
28.2.2. 流式语音合成
28.3. 语音唤醒
28.3.1. 范例

范例清单

8.1.
+
26.2. 设计模式
26.2.1. 单例模式
26.3. Android OS 包
26.3.1. 进程ID
26.3.2. handler
26.4. fastjson android
26.4.1. 对象转字符串
26.4.2. JsonObject 转对象
26.4.3. 字符串 与 json 互转
26.4.4. json 转 数组
26.4.5. JSON数组转List
26.4.6. Map 与 Json 互转
26.5. Butter Knife
26.6. Android Things
26.6.1. GPIO
27. FAQ
27.1. java.net.UnknownServiceException: CLEARTEXT communication to 192.168.0.185 not permitted by network security policy
27.2. Caused by: android.os.NetworkOnMainThreadException
27.3. java.lang.IllegalStateException: Player is accessed on the wrong thread.
27.4. Manifest merger failed with multiple errors, see logs
27.5. android.os.NetworkOnMainThreadException
27.6. package does not have vibrate permission
27.7. Can't create handler inside thread Thread[...,5,main] that has not called Looper.prepare()
27.8. java.lang.SecurityException: Permission denied (missing INTERNET permission?)
27.9. java.io.IOException: Cleartext HTTP traffic to **** not permitted
28. 讯飞云
28.1. AIUI
28.1.1. AIUIPlayer
28.1.2. 酷我音乐
28.1.3. 控制技能
28.1.4. 唤醒词
28.1.5. 汉字转拼音
28.2. 讯飞 TTS
28.2.1. 设置日志输出级别
28.2.2. 流式语音合成
28.3. 语音唤醒
28.3.1. 范例

范例清单

8.1.
diff --git a/android/location/ch15s02.html b/android/location/ch15s02.html index b85080223e..0cf1225a3e 100644 --- a/android/location/ch15s02.html +++ b/android/location/ch15s02.html @@ -1,6 +1,6 @@ 15.2. 只从 GPS 获取定位Home | 简体中文 | 繁体中文 | 杂文 - | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

15.2. 只从 GPS 获取定位

+ | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

15.2. 只从 GPS 获取定位

默认安卓系统使用 GPS + 网络定位,网络定位速度非常快,GPS 需要一些搜星。但是网络定位没有海拔高度数据,所以有些场景需要 GPS 定位。

diff --git a/android/location/index.html b/android/location/index.html
index 83b092cfce..492a1132d3 100644
--- a/android/location/index.html
+++ b/android/location/index.html
@@ -1,8 +1,8 @@
 
 第 15 章 定位Home | 简体中文 | 繁体中文 | 杂文
-		| Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

第 15 章 定位

+ | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

第 15 章 定位

-

15.1. GPS + 网络 定位

+

15.1. GPS + 网络 定位

15.1.1. manifest 权限配置

diff --git a/android/manifest/ch02s06.html b/android/manifest/ch02s06.html index ba0ed59fb8..b46c0a0404 100644 --- a/android/manifest/ch02s06.html +++ b/android/manifest/ch02s06.html @@ -1,6 +1,6 @@ 2.6. 全屏-无标题Home | 简体中文 | 繁体中文 | 杂文 - | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

2.6. 全屏-无标题

+ | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

2.6. 全屏-无标题

首先定义主题

diff --git a/android/manifest/ch02s07.html b/android/manifest/ch02s07.html
index a164705a82..df28287fdc 100644
--- a/android/manifest/ch02s07.html
+++ b/android/manifest/ch02s07.html
@@ -1,6 +1,6 @@
 
 2.7. 设置为默认开机启动Home | 简体中文 | 繁体中文 | 杂文
-		| Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

2.7. 设置为默认开机启动

+ | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

2.7. 设置为默认开机启动

 		
diff --git a/android/manifest/ch02s08.html b/android/manifest/ch02s08.html
index 93eaaeb0e0..5aad0e87ca 100644
--- a/android/manifest/ch02s08.html
+++ b/android/manifest/ch02s08.html
@@ -1,6 +1,6 @@
 
 2.8. 开机启动Home | 简体中文 | 繁体中文 | 杂文
-		| Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

2.8. 开机启动

+ | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

2.8. 开机启动

AndroidManifest.xml 配置

diff --git a/android/manifest/ch02s09.html b/android/manifest/ch02s09.html
index 138c6bd4c0..df71984df2 100644
--- a/android/manifest/ch02s09.html
+++ b/android/manifest/ch02s09.html
@@ -1,6 +1,6 @@
 
 2.9. 默认横屏Home | 简体中文 | 繁体中文 | 杂文
-		| Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

2.9. 默认横屏

+ | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

2.9. 默认横屏

android:screenOrientation="landscape"

diff --git a/android/media/AudioManager.html b/android/media/AudioManager.html
index f51da02a7b..c005315787 100644
--- a/android/media/AudioManager.html
+++ b/android/media/AudioManager.html
@@ -66,6 +66,15 @@
         Log.d(TAG, String.format("volume: currentMusicVolume=%s, currentTTSVolume=%s, maxVolume=%s", currentMusicVolume, currentTTSVolume, maxVolume));
     }		
 		
+		
+

关闭扬声器

+
+		
+audioManager = (AudioManager) mcontext.getSystemService(Context.AUDIO_SERVICE);
+audioManager.setSpeakerphoneOn(false);
+audioManager.setStreamVolume(AudioManager.STREAM_VOICE_CALL, 0, AudioManager.STREAM_VOICE_CALL);
+audioManager.setMode(AudioManager.MODE_IN_CALL);
+		
 		
\ No newline at end of file diff --git a/linux/voip/asterisk.html b/linux/voip/asterisk.html index 074ce7720c..0f90ad3ce7 100644 --- a/linux/voip/asterisk.html +++ b/linux/voip/asterisk.html @@ -5,7 +5,7 @@

http://www.asteriskpbx.com/

-

168.5.1. Redhat/CentOS/RockyLinux/AlmiLinux

+

168.5.1. Redhat/CentOS/RockyLinux/AlmiLinux

 			
@@ -147,7 +147,7 @@
 			
 		
-

168.5.2. 源码安装 asterisk-22

+

168.5.2. 源码安装 asterisk-22

 			
@@ -160,7 +160,7 @@
 			
 		
-

168.5.3. Ubuntu

+

168.5.3. Ubuntu

 			
@@ -199,7 +199,70 @@
 			
 		
-

168.5.4. 拨号规则设置

+

168.5.4. RasPBX – Asterisk for Raspberry Pi

+ +

http://www.raspberry-asterisk.org/

+
+

168.5.5. 配置文件

+ +

配置文件说明

+
+		
+asterisk.conf:主配置文件,通知Asterisk环境目录位置,包含其他所有配置文件所包含的目录,缺省Asterisk会在/etc/asterisk/目录下找到,也可以通过命令参数使用不同的asterisk.conf
+agents.conf:配置代理通道
+h323.conf:配置H323通道
+iax.conf:配置IAX通道
+mgcp.conf:配置MGCP(媒体网关控制协议,应用于多媒体网关单元之间)
+modem.conf:配置ISDN,不是modem
+phone.conf:配置linux电话设备
+sip.conf:配置SIP通道,可以添加sip用户,设置用户名,密码,拨号规则等。
+sip_notify.conf:配置SIP 消息通知
+skinny.conf:配置Cisco SCCP通道
+vpb.conf:配置Voicetronix卡通道(是澳大利亚的开放源码的CTI专业制造厂商)
+zapata.conf:配置ZAP Digium卡通道
+extensions.conf:Asterisk的具体拨号方案,它所有的操作控制和执行流程的主要方案,它控制呼入呼出如何别处理和路由。
+extensions.ael:扩展拨号方案语言
+features.conf:配置呼叫停泊,parking.conf文件名字已被修改为features.conf , 自定义按键配置,同时还有一些系统默认的功能键
+extconfig.conf:通过res_data方式部署扩展配置,例如通过ODBC
+alarmreceiver.conf:警报接收配置
+enum.conf:电话号码映射查找配置
+dundi.conf:分布式全球号码发现(DUNDi)是一个对等(P2P)协议,用于提供等价于那些由电子号码(ENUM)提供的服务。DUNDi有一个超过 ENUM的优点就是它更有弹力,因为也它缺乏一个故障中心点。DUNDi能够被用于增加DNS和它与IP语音(VOIP)服务一起发展。
+festival.conf:文本语音转换配置
+indications.conf:铃音清晰度配置
+meetme.conf:会议配置
+musiconhold.conf:音乐保持配置
+queues.conf:队列配置
+voicemail.conf:语音邮件配置,设置语音存储文件格式,分机号对应的语音邮箱密码和邮箱地址。
+alarmreceiver.conf:警报接收配置
+alsa.conf:致力于为Linux 提供高质量的声音子系统
+cdr_odbc.conf,cdr_pgsql.conf:通话详单数据库存储配置
+codecs.conf:Asterisk编码配置文件
+dnsmgr.conf:DNS管理(new in Asterisk v1.2)
+http.conf:内置http server配置,可以配置绑定的端口,可以访问的IP等。
+logger.conf:配置系统日志
+manager.conf:配置管理接口,设置管理员账号、密码、登录端口、访问权限等。
+modules.conf:配置可加载模块
+odbc.conf:ODBC驱动配置
+oss.conf:open source software配置
+privacy.conf:私密配置
+res_odbc.conf:实时数据库加载配置,可以把配置文件放在数据库中
+rpt.conf:循环应用配置
+rtp.conf:配置RTP(实时)端口
+say.conf:读出标准的数字和日期(new in Asterisk v1.4)
+users.conf:用户定义配置文件
+adsi.conf,asterisk.adsi,telcordia-1.adsi:配置模拟显示服务接口
+capi.conf:CAPI是计算机辅助面对面访问(Computer Assisted Personal Interviewing)的简称,是使用基于计算机的问卷的一种调研技术,CAPI可以像CATI一样控制复杂的逻辑,而且,它可以在各种各样的场所使用,购物中心,论坛或者其它公共场所,只要是被访者可以接触到电脑的地方。例如,在定点街访项目,借助端对端网络,它可以从容的管理问卷,控制配额,以及管理数据库,且不需要数据库服务器。 在面对面访问中,问卷可以由访问人员直接采用电脑,被访者同时可以查看的方式进行访问,也可以是被访者自己的电脑上看到电子问卷,自己操作访问。
+sirrix.conf:配置Sirrix ISDN通道
+cdr_mysql.conf:配置通话详单在mysql中存储
+prepaid.conf:预付费卡配置
+ldap.conf:访问x.500目录访问的标准协议
+bonjour.conf:苹果服务发现接口支持
+enumagi.conf:电话号码映射查找配置文件
+zeroconf.conf:zeroconf是一个轻量级的服务发现协议,适用于注册和寻找附近的可用协议、设备等等。 他是bonjour的开源名称,bonjour是苹果公司力推的一个service echotraining=yes   ;回音练习(会话前发个声音,用于测试回声)有关配置文件的语法规则,等以后再表。红色标出部分为自己首先要配置的部分。
+		
+		
+
+

168.5.6. 拨号规则设置

extensions.conf

@@ -233,7 +296,7 @@
 			
 		
-

168.5.5. pjsip

+

168.5.7. pjsip

 			
@@ -268,9 +331,9 @@
 		
-

168.5.6. 配置例子

+

168.5.8. 配置例子

-

168.5.6.1. sip.conf

+

168.5.8.1. sip.conf

@@ -415,7 +478,7 @@
-

168.5.6.2. pjsip.conf

+

168.5.8.2. pjsip.conf

 			
diff --git a/linux/voip/ch168s10.html b/linux/voip/ch168s10.html
new file mode 100644
index 0000000000..cb7290f4ea
--- /dev/null
+++ b/linux/voip/ch168s10.html
@@ -0,0 +1,171 @@
+
+168.10. sngrep - SIP Messages flow viewerHome | 简体中文 | 繁体中文 | 杂文
+		| Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

168.10. sngrep - SIP Messages flow viewer

+ +

168.10.1. Rocky Linux 安装 sngrep

+ + +
+		
+cat > /etc/yum.repos.d/irontec.repo <<EOF
+[irontec]
+name=Irontec RPMs repository
+baseurl=http://packages.irontec.com/centos/8/x86_64/
+EOF
+		
+			
+
+		
+[root@netkiller ~]# dnf search sngrep
+Last metadata expiration check: 0:00:04 ago on Thu 03 Apr 2025 09:37:24 AM CST.
+============================================ Name Exactly Matched: sngrep =============================================
+sngrep.src : SIP Messages flow viewer
+sngrep.x86_64 : SIP Messages flow viewer
+=========================================== Name & Summary Matched: sngrep ============================================
+sngrep-debuginfo.x86_64 : Debug information for package sngrep
+sngrep-debugsource.x86_64 : Debug sources for package sngrep
+		
+			
+
+		
+[root@netkiller ~]# rpm -import http://packages.irontec.com/public.key
+[root@netkiller ~]# dnf install sngrep
+		
+			
+
+		
+[root@netkiller ~]# sngrep -V
+sngrep - 1.4.7
+Copyright (C) 2013-2018 Irontec S.L.
+License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
+This is free software: you are free to change and redistribute it.
+There is NO WARRANTY, to the extent permitted by law.
+ * Compiled with Wide-character support.
+ * Compiled with Perl Compatible regular expressions support.
+ * Compiled with IPv6 support.
+ * Compiled with EEP/HEP support.
+
+Written by Ivan Alonso [aka Kaian]
+		
+			
+
+

168.10.2. MacOS

+ +
+			
+brew install sngrep
+			
+			
+
+

168.10.3. debian 安装sngrep

+ +
+			
+echo "deb http://packages.irontec.com/debian jessie main" >> /etc/apt/sources.list
+wget http://packages.irontec.com/public.key -q -O - | apt-key add -
+apt-get install sngrep -y
+			
+			
+
+

168.10.4. 命令行参数

+ +
+			
+[root@netkiller ~]# sngrep --HELP
+- option requires an argument.
+[root@netkiller ~]# sngrep --help
+Usage: sngrep [-hVcivNqrD] [-IO pcap_dump] [-d dev] [-l limit] [-B buffer] [-LH capture_url] [<match expression>] [<bpf filter>]
+
+    -h --help            This usage
+    -V --version         Version information
+    -d --device          Use this capture device instead of default
+    -I --input           Read captured data from pcap file
+    -O --output          Write captured data to pcap file
+    -B --buffer          Set pcap buffer size in MB (default: 2)
+    -c --calls           Only display dialogs starting with INVITE
+    -r --rtp             Capture RTP packets payload
+    -l --limit           Set capture limit to N dialogs
+    -i --icase           Make <match expression> case insensitive
+    -v --invert          Invert <match expression>
+    -N --no-interface    Don't display sngrep interface, just capture
+    -q --quiet           Don't print captured dialogs in no interface mode
+    -D --dump-config     Print active configuration settings and exit
+    -f --config          Read configuration from file
+    -F --no-config       Do not read configuration from default config file
+    -R --rotate          Rotate calls when capture limit have been reached
+    -H --eep-send        Homer sipcapture url (udp:X.X.X.X:XXXX)
+    -L --eep-listen      Listen for encapsulated packets (udp:X.X.X.X:XXXX)			
+			
+			
+
+			
+-h --help: 显示帮助信息
+-V --version: 显示版本信息
+-d --device: 指定抓包的网卡
+-I --input: 从pacp文件中解析sip包
+-O --output: 输出捕获的包到pacp文件中
+-c --calls: 仅显示invite消息
+-r --rtp: Capture RTP packets payload 捕获rtp包
+-l --limit: 限制捕获对话的数量
+-i --icase: 使大小写不敏感
+-v --invert: 颠倒(不太明白)
+-N --no-interface: Don’t display sngrep interface, just capture
+-q --quiet: Don’t print captured dialogs in no interface mode
+-D --dump-config: Print active configuration settings and exit
+-f --config: Read configuration from file
+-R --rotate: Rotate calls when capture limit have been reached.
+-H --eep-send: Homer sipcapture url (udp:X.X.X.X:XXXX)
+-L --eep-listen: Listen for encapsulated packets (udp:X.X.X.X:XXXX)
+-k --keyfile: RSA private keyfile to decrypt captured packets
+			
+			
+
+

168.10.5. UI 快捷鍵

+ +
+			
+Arrow keys: Move through the list,除了上下箭头还可以使用j,k来移动光标
+Enter: Display current or selected dialog(s) message flow
+A: Auto scroll to new calls,自动滚动到新的call
+F2 or s: Save selected/all dialog(s) to a PCAP file, 保存dialog到pacp文件
+F3 or / or TAB: Enter a display filter. This filter will be applied to the text lines in the list,进入搜索
+F4 or x: Display current selected dialog and its related one. 回到第一个sip消息上
+F5: Clear call list, 清空呼叫列表
+F6 or r: Display selected dialog(s) messages in raw text, 显示原始的sip消息
+F7 or f: Show advanded filters dialogs 显示高级过滤弹窗
+F9 or l: Turn on/off address resolution if enabled
+F10 or t: Select displayed columns, 显示或者隐藏侧边sip消息栏			
+			
+			
+
+
\ No newline at end of file diff --git a/linux/voip/client.html b/linux/voip/client.html index 751db2183b..ea5e2dfc50 100644 --- a/linux/voip/client.html +++ b/linux/voip/client.html @@ -1,15 +1,15 @@ -168.8. SIP/H.323 客户端Home | 简体中文 | 繁体中文 | 杂文 - | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

168.8. SIP/H.323 客户端

+168.9. SIP/H.323 客户端Home | 简体中文 | 繁体中文 | 杂文 + | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

168.9. SIP/H.323 客户端

-

168.8.1. linphone

+

168.9.1. linphone

跨平台开源免费的 SIP 客户端

https://www.linphone.org

-
\ No newline at end of file diff --git a/linux/voip/vocal.html b/linux/voip/vocal.html index 30e0c8412d..20641cd399 100644 --- a/linux/voip/vocal.html +++ b/linux/voip/vocal.html @@ -1,9 +1,9 @@ -168.7. VOCAL (includes a SIP to H.323 translator)Home | 简体中文 | 繁体中文 | 杂文 - | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

168.7. VOCAL (includes a SIP to H.323 translator)

+168.7. VOCAL (includes a SIP to H.323 translator)Home | 简体中文 | 繁体中文 | 杂文 + | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

168.7. VOCAL (includes a SIP to H.323 translator)

http://www.vovida.org/

-