Android Nativescript重写getPackageName

Android Nativescript重写getPackageName,android,nativescript,android-webview,nativescript-vue,Android,Nativescript,Android Webview,Nativescript Vue,我正在开发一个使用webview的android应用程序。但是,webview总是将X-request-with头添加到所有请求中 在阅读相关文章时,我遇到了这样一个问题:如果覆盖应用程序中的getPackageName函数,它就会工作 现在,在我的nativescript应用程序中,我添加了文件application.android.js,更改为AndroidManifext,并让它运行。在这个文件中,我做了如下工作 // the first parameter of the `extend`

我正在开发一个使用webview的android应用程序。但是,webview总是将
X-request-with
头添加到所有请求中

在阅读相关文章时,我遇到了这样一个问题:如果覆盖应用程序中的
getPackageName
函数,它就会工作

现在,在我的nativescript应用程序中,我添加了文件
application.android.js
,更改为
AndroidManifext
,并让它运行。在这个文件中,我做了如下工作

// the first parameter of the `extend` call defines the package and the name for the native *.JAVA file generated.
android.app.Application.extend("com.name.app", {
    onCreate: function() {
        superProto.onCreate.call(this);

        // At this point modules have already been initialized
        console.log('hererere')
        // Enter custom initialization code here
    },
    attachBaseContext: function(base) {
        superProto.attachBaseContext.call(this, base);
        // This code enables MultiDex support for the application (if needed compile androidx.multidex:multidex)
        // androidx.multidex.MultiDex.install(this);
    },
    getPackageName: function(){
        console.log("getting packagee name")
        try {
            let stackTrace = java.lang.Thread.currentThread().getStackTrace();
            console.log(stackTrace)
            for (var i = 0; i< stackTrace.length ; i++) {
                let element = stackTrace[i]
                console.log("\t" + element.getClassName(), element.getMethodName());
                if ("org.chromium.base.BuildInfo".toLowerCase() === element.getClassName().toLowerCase()) {
                    if ("getAll".toLowerCase() === (element.getMethodName()).toLowerCase()) {
                        customPackageName = "";
                        return customPackageName;
                    }
                    break;
                }
            }
        } catch (e) {
            console.log(e)

         }
        

        return "com.name.app"
      
    }
});
//extend`调用的第一个参数定义生成的本机*.JAVA文件的包和名称。
android.app.Application.extend(“com.name.app”{
onCreate:function(){
superProto.onCreate.call(this);
//此时模块已经初始化
console.log('hererere')
//在此处输入自定义初始化代码
},
attachBaseContext:函数(基本){
superProto.attachBaseContext.call(this,base);
//此代码为应用程序启用多索引支持(如果需要,请编译androidx.MultiDex:MultiDex)
//androidx.multidex.multidex.install(这个);
},
getPackageName:函数(){
console.log(“获取程序包名称”)
试一试{
让stackTrace=java.lang.Thread.currentThread().getStackTrace();
console.log(stackTrace)
对于(var i=0;i
我在这个文件中看到一些关于getPackageName的请求。但没有一个是来自浏览器的。这是正确的吗?我错过什么了吗?应该如何实施这一点