吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 195|回复: 1
收起左侧

[Android 求助] xpose模块生成弹窗问题

[复制链接]
qingjiu123 发表于 2025-3-17 17:36
给一个软件添加生成弹窗模块,用aide写的xpose
遇到的问题是
第一弹窗没有生成,具体原因我也不知道,
如果有可能的话,请指导一下,是资源加载的问题吗?但是我觉得应该不是吧,模块生成,我用onpath(手机没有root)
第二想知道这个日志应该怎么去查看?需要注意什么?
希望查看日志详细一点日志的话,详细一点
[Asm] 纯文本查看 复制代码
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
public class MainModule implements IXposedHookLoadPackage {
 
    // 目标应用的包名
    private static final String TARGET_PACKAGE = "com.justsoso.faster";
 
    @Override
    public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable {
        // 检查当前加载的应用是否是目标应用
        if (!lpparam.packageName.equals(TARGET_PACKAGE)) {
            return; // 如果不是目标应用,直接返回
        }
 
        // 获取模块的资源路径
        final String modulePath = lpparam.appInfo.sourceDir;
 
        // 挂钩到 Application.attach 方法,加载模块资源
        XposedHelpers.findAndHookMethod(Application.class, "attach", Context.class, new XC_MethodHook() {
                @Override
                protected void afterHookedMethod(MethodHookParam param) throws Throwable {
                    Context context = (Context) param.args[0];
 
                    // 将模块的资源路径添加到目标应用的 AssetManager
                    XposedHelpers.callMethod(context.getResources().getAssets(), "addAssetPath", modulePath);
                }
            });
 
        XposedHelpers.findAndHookMethod(
            "com.faster.cheetah.MainActivity",
            lpparam.classLoader,
            "onCreate", // 在 onResume 中操作视图
            new XC_MethodHook() {
                @Override
                protected void afterHookedMethod(MethodHookParam param) throws Throwable {
                    Activity activity = (Activity) param.thisObject;
 
                    // 确保 DecorView 已初始化
                    View decorView = activity.getWindow().getDecorView();
                    if (decorView != null) {
                        // 显示自定义弹窗
                        showCustomDialog(activity);
                    } else {
                        XposedBridge.log("DecorView 未初始化,无法显示弹窗");
                    }
                }
            }
        );
    }
 
    /**
     * 显示自定义弹窗
     *
     * [url=home.php?mod=space&uid=952169]@Param[/url] activity 当前的 Activity 对象
     */
    private void showCustomDialog(Activity activity) {
        try {
            // 使用 LayoutInflater 加载自定义布局
            LayoutInflater inflater = LayoutInflater.from(activity);
            View dialogView = inflater.inflate(R.layout.dialog_custom, null);
 
            // 获取布局中的控件
            ImageView imageView = dialogView.findViewById(R.id.imageView);
            TextView messageTextView = dialogView.findViewById(R.id.messageTextView);
 
            // 设置图片和文字
            imageView.setImageResource(R.drawable.custom_image); // 替换为你的图片资源
            messageTextView.setText("这是一个自定义弹窗!"); // 替换为你的文字内容
 
            // 创建弹窗
            AlertDialog.Builder builder = new AlertDialog.Builder(activity);
            builder.setView(dialogView);
            builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss(); // 点击确定按钮后关闭弹窗
                    }
                });
 
            // 显示弹窗
            AlertDialog dialog = builder.create();
            dialog.show();
        } catch (Exception e) {
            // 输出日志
            XposedBridge.log("弹窗加载失败: " + e.getMessage());
        }
    }
}

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

 楼主| qingjiu123 发表于 2025-3-18 06:10
????
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2025-4-3 07:29

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表