Xposed之app内直接页面跳转思路

有时候我们想在某个app内不用手点击就跳转到指定的页面,比如打开新闻app首页后想直接跳转到指定文章内。
首先想到的是andord开发页面跳转传值一般用的是Extra,那么需要先hook到文章详情页看看接受到传过来的值有哪些,我们才能在首页跳转时候把值传过去。

1、查看详情页,看看app正常点击打开文章传过来的值有哪些,hook到详情页的包名和activity名字全路径。然后手动后点击跳转时候会打印传过来的值。

Class<?> mainActivity = XposedHelpers.findClass("xxx.xxxx.xxxxx", classLoader);
XposedHelpers.findAndHookMethod(mainActivity, "onCreate", Bundle.class, new XC_MethodHook() {
    @Override
    protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
        super.beforeHookedMethod(param);
    }

    @Override
    protected void afterHookedMethod(MethodHookParam param) throws Throwable {
        super.afterHookedMethod(param);
        Activity activity = (Activity) param.thisObject;
        if (activity != null) {
            Intent getIntent = activity.getIntent();
            Bundle bundle = getIntent.getExtras();
            for (String key : bundle.keySet()) {
                Log.i("extras", "Key=" + key + ", content=" + bundle.getString(key));
            }
        }
    }
});

2、打印出来正常打开文章传过来的值有哪些,然后我们在打开app首页时候直接调起文章详情页面,传值就好了。这样就不用手点击自动打开文章了。

   Class<?> mainActivity = XposedHelpers.findClass("xxxx.xxxx.xx.MainActivity", classLoader);
        XposedHelpers.findAndHookMethod(mainActivity, "onCreate", Bundle.class, new XC_MethodHook() {
            @Override
            protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
                super.beforeHookedMethod(param);
            }

            @Override
            protected void afterHookedMethod(MethodHookParam param) throws Throwable {
                super.afterHookedMethod(param);
                final Activity activity = (Activity) param.thisObject;
                if (activity != null) {
                    Log.e("hook", "获取到上下文");
                    JSONObject jsonObject = new JSONObject();
                    jsonObject.put("id", "1111111111");
                    jsonObject.put("title", "王者小鳄鱼");
                    jsonObject.put("msg", "111111");
                    Intent intent = new Intent();
                    intent.setClassName(activity, "xxxx.xxx.文章详情页面activity");
                    intent.putExtra("imd", "1");
                    intent.putExtra("meg", "23");
                    intent.putExtra("json", jsonObject.toString());
                    activity.startActivity(intent);
                }
            }
        });

这样就可以再打开app时候直接跳转到指定文章的详情页面了,这里传的值有文章id等

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值