Skip to content

Commit c68f55a

Browse files
committed
Merge branch 'master' of https://github.com/ikws4/KXposedHelper
2 parents 13d5627 + 2583aa3 commit c68f55a

File tree

2 files changed

+98
-2
lines changed

2 files changed

+98
-2
lines changed

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 zhiping
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 77 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,17 @@ allprojects {
1818
Step 2. Add the dependency
1919
```gradle
2020
dependencies {
21-
implementation 'com.github.ikws4:KXposedHelper:1.0'
21+
implementation 'com.github.ikws4:KXposedHelper:1.1'
2222
}
2323
```
2424

2525
# Catalogue
2626
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)
2732
2. [How to use KXSharedPreferences?](#How-to-use-KXSharedPreferences?)
2833
3. [How to use KXBroadcastReceiver?](#How-to-use-KXBroadcastReceiver?)
2934

@@ -39,7 +44,7 @@ KXposedHelpers.findAndHookMethod(Activity::class, "onCreate", parameterTypes = a
3944
})
4045
```
4146

42-
#### Before and After Hook
47+
#### Before and after hook
4348
```kotlin
4449
KXposedHelpers.findAndHookMethod(Activity::class, "onStart", methodHook = MethodHook(
4550
beforeHookedMethod = { param->
@@ -62,6 +67,18 @@ KXposedHelpers.findAndHookMethod(TextView::class, "getText", methodHook = Method
6267
})
6368
```
6469

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+
6582
### How to use KXSharedPreferences?
6683
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.
6784

@@ -81,3 +98,61 @@ sp.getString("key","defValue")
8198

8299
### How to use KXBroadcastReceiver?
83100
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

Comments
 (0)