gpt4 book ai didi

android - Ionic 应用程序 - 无法访问互联网

转载 作者:行者123 更新时间:2023-11-29 17:23:38 24 4
gpt4 key购买 nike

我使用 ionic 和 Phonegap 构建了一个小型移动 Android 6 应用程序。这不是我的第一个 Hybrid 应用程序,但却是我第一个使用 Ionic 的应用程序。该应用程序调用一个 php 文件来查询 MySQL 数据库并将一些信息返回到 View 。该应用程序可根据需要在线和本地运行,但在我通过 PhoneGap 构建后无法访问互联网。我的样式以及从 PHP 调用返回的信息都没有加载。我已经通过 PhoneGap 发布了该应用程序,并通过 Samsung galaxy 5 进行了测试;我在 Mac 上开发了所有内容。

我根据需要安装了 Cordova 白名单插件,并向 list 添加了必要的权限,但我需要另一双眼睛来检查这个。

这是我的 config.xml 文件:

配置文件

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<widget id="com.ionicframework.testrest902325" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>NAME</name>
<description>
DESCRIPTION
</description>
<author email="name@name.edu" href="http://example.com.com/">
</author>
<content src="index.html"/>
<access origin="*"/>
<preference name="webviewbounce" value="false"/>
<preference name="UIWebViewBounce" value="false"/>
<preference name="DisallowOverscroll" value="true"/>
<preference name="android-minSdkVersion" value="16"/>
<preference name="BackupWebStorage" value="none"/>
<feature name="StatusBar">
<param name="ios-package" value="CDVStatusBar" onload="true"/>
</feature>
</widget>

这是我的 AndroidManifest.xml

<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="1" android:versionName="0.0.1" package="com.ionicframework.testrest902325" xmlns:android="http://schemas.android.com/apk/res/android">
<supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<application android:hardwareAccelerated="true" android:icon="@drawable/icon" android:label="@string/app_name" android:supportsRtl="true">
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="@android:style/Theme.DeviceDefault.NoActionBar" android:windowSoftInputMode="adjustResize">
<intent-filter android:label="@string/launcher_name">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="23" />
</manifest>

最佳答案

我遇到了非常相似的问题;即使安装了白名单插件并获得了必要的权限,我的应用程序也从未连接到我的网络服务。

然后我想试试在 config.xml 中包含白名单插件。因此,在我的项目文件夹中,我运行了以下更新了我的 config.xml 的命令

cordova plugin add cordova-plugin-whitelist --save

之后,由我的自动构建系统生成的 APK 连接到我的网络服务。

关于android - Ionic 应用程序 - 无法访问互联网,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35539437/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com