|
@@ -8,6 +8,7 @@ import android.util.Log
|
8
|
8
|
import android.widget.Toast
|
9
|
9
|
import com.xhly.corelib.Const
|
10
|
10
|
import com.xhly.corelib.eventbus.UIEvent
|
|
11
|
+import com.xhly.corelib.utils.LogShow
|
11
|
12
|
import com.xhly.manageapp.utils.InstallUtils
|
12
|
13
|
|
13
|
14
|
//(自定义广播类) --自己命名的 XXXXReceiver
|
|
@@ -15,20 +16,19 @@ class AppInstallReceiver : BroadcastReceiver() {
|
15
|
16
|
private val TAG = this.javaClass.simpleName
|
16
|
17
|
override fun onReceive(context: Context, intent: Intent) {
|
17
|
18
|
val pm = context.packageManager
|
18
|
|
- Log.i("执行监听", "--------应用监听" + intent.data!!.schemeSpecificPart)
|
19
|
19
|
if (TextUtils.equals(intent.action, Intent.ACTION_PACKAGE_ADDED)) {
|
20
|
20
|
val packageName = intent.data!!.schemeSpecificPart
|
21
|
|
- Log.i(TAG, "--------安装成功$packageName")
|
22
|
21
|
//Toast.makeText(context, "安装成功$packageName", Toast.LENGTH_LONG).show()
|
|
22
|
+ LogShow("--------安装成功$packageName")
|
23
|
23
|
InstallUtils.installSuccess(packageName)
|
24
|
24
|
UIEvent(Const.APPINSTALL).setMessage(packageName).post()
|
25
|
25
|
} else if (TextUtils.equals(intent.action, Intent.ACTION_PACKAGE_REPLACED)) {
|
26
|
26
|
val packageName = intent.data!!.schemeSpecificPart
|
27
|
|
- Log.i(TAG, "--------替换成功$packageName")
|
|
27
|
+ LogShow("--------替换成功$packageName")
|
28
|
28
|
// Toast.makeText(context, "替换成功$packageName", Toast.LENGTH_LONG).show()
|
29
|
29
|
} else if (TextUtils.equals(intent.action, Intent.ACTION_PACKAGE_REMOVED)) {
|
30
|
30
|
val packageName = intent.data!!.schemeSpecificPart
|
31
|
|
- Log.i(TAG, "--------卸载成功$packageName")
|
|
31
|
+ LogShow("--------卸载成功$packageName")
|
32
|
32
|
// Toast.makeText(context, "卸载成功$packageName", Toast.LENGTH_LONG).show()
|
33
|
33
|
UIEvent(Const.APPUNINSTALL).setMessage(packageName).post()
|
34
|
34
|
}
|