|
@@ -0,0 +1,28 @@
|
|
1
|
+package com.xhly.manageapp.broadcastreceiver
|
|
2
|
+
|
|
3
|
+import android.content.BroadcastReceiver
|
|
4
|
+import android.content.Context
|
|
5
|
+import android.content.Intent
|
|
6
|
+
|
|
7
|
+class SDReceiver: BroadcastReceiver() {
|
|
8
|
+ override fun onReceive(context: Context, intent: Intent) {
|
|
9
|
+ val action = intent.action
|
|
10
|
+ when (action) {
|
|
11
|
+ Intent.ACTION_MEDIA_CHECKING->
|
|
12
|
+ {
|
|
13
|
+ //SD卡正在检查
|
|
14
|
+ }
|
|
15
|
+ Intent.ACTION_MEDIA_MOUNTED->
|
|
16
|
+ {
|
|
17
|
+ //SD卡挂载成功
|
|
18
|
+ }
|
|
19
|
+ Intent.ACTION_MEDIA_EJECT->{
|
|
20
|
+ //SD卡拔出
|
|
21
|
+
|
|
22
|
+ }
|
|
23
|
+ Intent.ACTION_MEDIA_UNMOUNTED->{
|
|
24
|
+ //SD卡卸载成功
|
|
25
|
+ }
|
|
26
|
+ }
|
|
27
|
+ }
|
|
28
|
+}
|