Implementing a WeChat Zombie‑Friend Detection Tool Using Android AccessibilityService
This article walks through building an Android AccessibilityService‑based tool that automatically detects WeChat contacts who have deleted or blocked you by using a fake‑transfer method, handling UI events, launching WeChat, and employing Kotlin code snippets for node navigation and gesture simulation.
0x1 Introduction
In the previous lesson we covered the basics of Android AccessibilityService and built a simple WeChat auto‑login demo. This article continues with a practical scenario: detecting “zombie” friends in WeChat – contacts that have deleted or blocked you without obvious UI hints.
0x2 How to judge deletion/blacklist – Fake Transfer Method
Instead of mass messaging or group‑inviting, we use the “fake transfer” technique. By opening the transfer page and checking the nickname field we can infer four possible states: normal friend, deleted, blacklisted, or abnormal account, based on the system prompts.
0x3 Practical Implementation
① UI Design
Reuse the previous settings page, add a “Clean” button, and create a simple result list using a RecyclerView.
② Jump to WeChat
Two ways to launch another app: specify package and activity with an Intent , or use a URL scheme. Sample Kotlin functions are provided.
fun Context.startApp(packageName: String, activityName: String, errorTips: String) {
try {
startActivity(Intent(Intent.ACTION_VIEW).apply {
component = ComponentName(packageName, activityName)
flags = Intent.FLAG_ACTIVITY_NEW_TASK
})
} catch (e: ActivityNotFoundException) {
shortToast(errorTips)
} catch (e: Exception) {
e.message?.let { logD(it) }
}
}
fun Context.startApp(urlScheme: String, errorTips: String) {
try {
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(urlScheme)))
} catch (e: ActivityNotFoundException) {
shortToast(errorTips)
} catch (e: Exception) {
e.message?.let { logD(it) }
}
}③ Event Trigger Chain
Set android:accessibilityEventTypes="typeWindowStateChanged|typeViewClicked" and listen for events such as TYPE_WINDOW_STATE_CHANGED with class names like com.tencent.mm.ui.LauncherUI (home), com.tencent.mm.plugin.profile.ui.ContactInfoUI (contact page), com.tencent.mm.ui.chatting.ChattingUI (chat page), etc.
④ Modify Accessibility Config
Define a service XML that restricts monitoring to the WeChat package and enables gesture support.
<accessibility-service xmlns:android="http://schemas.android.com/apk/res/android"
android:description="@string/accessibility_desc"
android:accessibilityEventTypes="typeWindowStateChanged|typeViewClicked"
android:accessibilityFeedbackType="feedbackSpoken"
android:accessibilityFlags="flagReportViewIds|flagIncludeNotImportantViews"
android:canRetrieveWindowContent="true"
android:notificationTimeout="100"
android:canPerformGestures="true"
android:packageNames="com.tencent.mm"
android:settingsActivity="cn.coderpig.clearcorpse.SettingActivity" />⑤ Click Contacts Tab
After launching WeChat, locate the “Contacts” tab by its text and invoke .click() on its parent node because the text node itself is not clickable.
⑥ Friend List Click
Find the contact list view by its resource ID (e.g., "js"), then click the first item using the helper getNodeById method.
⑦ Contact Page – Send Message
Extract the WeChat ID from the contact page and trigger the “Send Message” button.
⑧ Chat Page – Click + and Transfer
When a normal click does not work, simulate a tap with a gesture.
fun AccessibilityService.gestureClick(node: AccessibilityNodeInfo?) {
if (node == null) return
val tempRect = Rect()
node.getBoundsInScreen(tempRect)
val x = ((tempRect.left + tempRect.right) / 2).toFloat()
val y = ((tempRect.top + tempRect.bottom) / 2).toFloat()
dispatchGesture(
GestureDescription.Builder().apply {
addStroke(GestureDescription.StrokeDescription(Path().apply { moveTo(x, y) }, 0L, 200L))
}.build(),
object : AccessibilityService.GestureResultCallback() {
override fun onCompleted(gestureDescription: GestureDescription?) {
super.onCompleted(gestureDescription)
logD("Gesture click completed at [$x, $y]")
}
},
null
)
}⑨ Transfer Page Logic
Enter 0.01 RMB, submit, and interpret the resulting dialog: a red exclamation indicates deletion, a “you are not the recipient” message indicates blacklist, a password entry indicates a normal friend.
Combining all utilities yields a fully automated WeChat zombie‑friend detection tool.
Rare Earth Juejin Tech Community
Juejin, a tech community that helps developers grow.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.