2025年3月21日 星期五 甲辰(龙)年 月廿 设为首页 加入收藏
rss
您当前的位置:首页 > 计算机 > 编程开发 > 安卓(android)开发

Android中无法访问http类型网址的解决办法

时间:03-18来源:作者:点击数:45

1.解决方案一:

将http改成https

2.解决方案二:

在Manifest文件中添加android:usesCleartextTraffic="true",如下所示:

  • <?xml version="1.0" encoding="utf-8"?>
  • <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  • xmlns:tools="http://schemas.android.com/tools"
  • package="com.example.myapplication">
  • <uses-permission android:name="android.permission.INTERNET" />
  • <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
  • <application
  • android:allowBackup="true"
  • android:dataExtractionRules="@xml/data_extraction_rules"
  • android:fullBackupContent="@xml/backup_rules"
  • android:icon="@mipmap/ic_launcher"
  • android:label="@string/app_name"
  • android:roundIcon="@mipmap/ic_launcher_round"
  • android:supportsRtl="true"
  • android:theme="@style/Theme.MyApplication"
  • android:usesCleartextTraffic="true"//添加这一行代码
  • tools:targetApi="31">
  • <service android:name=".DownloadService"></service>
  • <activity
  • android:name=".MainActivity"
  • android:exported="true">
  • <intent-filter>
  • <action android:name="android.intent.action.MAIN" />
  • <category android:name="android.intent.category.LAUNCHER" />
  • </intent-filter>
  • </activity>
  • </application>
  • </manifest>
方便获取更多学习、工作、生活信息请关注本站微信公众号城东书院 微信服务号城东书院 微信订阅号
推荐内容
相关内容
栏目更新
栏目热门