android - NativeScript HTTP 获取请求不起作用。安卓版本问题?
问题描述
我一直在研究 node.js 后端应用程序。现在我想开始对前端进行编程,但我在执行 HTTP 请求时遇到了困难。我有一个用于测试的物理平板电脑三星 Galaxy Tab Active2,但简单的 GET 请求在这款装有 Android 版本 9 的平板电脑上不起作用。
我尝试在 Android 8.1 上使用 HTTP 请求运行完全相同的应用程序,并且它工作正常。我正在返回内容。
getTest() {
console.log('test')
httpModule
.request({
url: "http://XXX.XXX.XXX.XXX:8080/XXX/XXX",
method: "GET"
})
.then(
response => {
// Content property of the response is HttpContent
// The toString method allows you to get the response body as string.
const str = response.content.toString();
const head = response.headers.toString();
console.log("Content:" + str + " Header: " + head );
// The toJSON method allows you to parse the received content to JSON object
// var obj = response.content.toJSON();
// The toImage method allows you to get the response body as ImageSource.
// var img = response.content.toImage();
},
e => {}
);
}
版本 8.1 模拟器为我提供了内容,但我在 Android 版本 9 上运行的物理平板电脑仅将输出“测试”提供给控制台。它不会连接到我的后端(我配置了一个记录器,它在请求中提供输出)。
解决方案
推荐阅读
- excel - 将数组值与列单元格值匹配以格式化工作表
- c++ - 通过引用返回c ++中的对象
- sql - 如何在 SSRS 中使用 IIF 语句计算 DateDiff 时修复 #Error
- javascript - 如何在 Spotfire 文本区域中动态更改 html 标签的背景颜色
- unit-testing - ngrx testing: Uncaught TypeError: Cannot read property 'xxxx' of undefined thrown
- amazon-web-services - Container is not able to call S3 in Fargate
- angular - Issue with Dynamic Titles in Angular 2+ when switching tabs
- r - Subset table by replacing some row values
- php - 创建空表并插入数据
- vimeo - 显示没有密码的受密码保护的 Vimeo 视频