@@ -18,12 +18,17 @@ allprojects {
18
18
Step 2. Add the dependency
19
19
``` gradle
20
20
dependencies {
21
- implementation 'com.github.ikws4:KXposedHelper:1.0 '
21
+ implementation 'com.github.ikws4:KXposedHelper:1.1 '
22
22
}
23
23
```
24
24
25
25
# Catalogue
26
26
1 . [ How to hook method?] ( #How-to-hook-method? )
27
+ 1 . [ Simple to use] ( #Simple-to-use )
28
+ 2 . [ Before and after hook] ( #Before-and-after-hook )
29
+ 3 . [ Replece method] ( #Replece-method )
30
+ 4 . [ Change return value] ( #Change-return-value )
31
+ 5 . [ Some utilities in hook] ( #Some-utilities-in-hook )
27
32
2 . [ How to use KXSharedPreferences?] ( #How-to-use-KXSharedPreferences? )
28
33
3 . [ How to use KXBroadcastReceiver?] ( #How-to-use-KXBroadcastReceiver? )
29
34
@@ -39,7 +44,7 @@ KXposedHelpers.findAndHookMethod(Activity::class, "onCreate", parameterTypes = a
39
44
})
40
45
```
41
46
42
- #### Before and After Hook
47
+ #### Before and after hook
43
48
``` kotlin
44
49
KXposedHelpers .findAndHookMethod(Activity ::class , " onStart" , methodHook = MethodHook (
45
50
beforeHookedMethod = { param->
@@ -62,6 +67,18 @@ KXposedHelpers.findAndHookMethod(TextView::class, "getText", methodHook = Method
62
67
})
63
68
```
64
69
70
+ #### Some utilities in hook
71
+ ``` kotlin
72
+ // ActivityHookHelper for Activity lifecycle hook
73
+ ActivityHookHelper .onCreate { }
74
+ ActivityHookHelper .onDestroy { }
75
+ .. .
76
+
77
+ // ApplicationHookHelper
78
+ ApplicationHookHelper .onCreate { }
79
+ ApplicationHookHelper .attach { }
80
+ ```
81
+
65
82
### How to use KXSharedPreferences?
66
83
In high Android version, because the security permission, and the XSharedPreferences not working very well, so I created the utility for SharedPreferences called KXSharedPreferences, it's use the ContentProvider to shared preferences across the applications.
67
84
@@ -81,3 +98,61 @@ sp.getString("key","defValue")
81
98
82
99
### How to use KXBroadcastReceiver?
83
100
Sometimes you need to receive some broadcasts from your app, so this can help you easily to receiver broadcasts.
101
+
102
+ Step 1. you need to implement KXBroadcastReceiver.
103
+ ``` kotlin
104
+ class BarBroadReceiver : KXBroadcastReceiver () {
105
+ override val intentFilter: IntentFilter
106
+ get() = IntentFilter ().apply {
107
+ addAction(" Action1" )
108
+ addAction(" Action2" )
109
+ }
110
+ }
111
+ ```
112
+
113
+ Step 2. register, unregister and listening
114
+ ``` kotlin
115
+ val barBroadReceiver = BarBroadReceiver ()
116
+
117
+ barBroadReceiver.setOnReceiveListener { context, intent ->
118
+ when (intent.action) {
119
+ " Action1" -> {
120
+ }
121
+ " Action2" -> {
122
+ }
123
+ }
124
+ }
125
+
126
+ ActivityHookHelper .onCreate {
127
+ barBroadReceiver.register(this )
128
+ }
129
+
130
+ ActivityHookHelper .onDestroy {
131
+ barBroadReceiver.unRegister(this )
132
+ }
133
+ ```
134
+
135
+ ## LICENSE
136
+ ```
137
+ MIT License
138
+
139
+ Copyright (c) 2020 zhiping
140
+
141
+ Permission is hereby granted, free of charge, to any person obtaining a copy
142
+ of this software and associated documentation files (the "Software"), to deal
143
+ in the Software without restriction, including without limitation the rights
144
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
145
+ copies of the Software, and to permit persons to whom the Software is
146
+ furnished to do so, subject to the following conditions:
147
+
148
+ The above copyright notice and this permission notice shall be included in all
149
+ copies or substantial portions of the Software.
150
+
151
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
152
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
153
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
154
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
155
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
156
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
157
+ SOFTWARE.
158
+ ```
0 commit comments