如何修改android webview的x-request-with字段默认的包名

/ 默认分类 / 没有评论 / 29浏览
package com.ug;

import android.app.Application;

public class CustomApplication extends Application {

    @Override
    public String getPackageName() {
        StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
        for (StackTraceElement item : stackTrace) {
            if ("org.chromium.base.BuildInfo".equals(item.getClassName())) {
                if ("getAll".equals(item.getMethodName())) {
                    return "com.baidu.sdk";
                }
            }
        }
        return super.getPackageName();
    }
}