gpt4 book ai didi

android - Internet Access 不适用于 Android 1.6,但适用于 2.0/2.1/2.2

转载 作者:行者123 更新时间:2023-11-30 04:48:31 25 4
gpt4 key购买 nike

我正在尝试在我的 android Activity 中使用 jsoup (1.3.3) 解析一些 html。当我调用这段代码时

Jsoup.connect("http://www.google.com").get();

它在 android 2.1 和 2.2 中运行良好,但在 1.6 中我得到一个“java.io.IOException: 403 Error loading URL”。

我正在使用模拟器对此进行测试,我注意到 admob 广告也未在 1.6 中显示,但它们在 2.0、2.1 和 2.2 中有效。

在 1.6 模拟器中使用网络浏览器确实有效,所以我非常确信问题出在我的代码中。

在 1.6 中是否需要一些额外的权限才能在 2.0+ 中访问互联网?

这是我的 list 文件的结构,uses-permission 标签的位置有什么影响吗?

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.foo.bar"
android:versionCode="1"
android:versionName="1.0"
android:installLocation="auto">

<application android:icon="@drawable/icon"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar"
android:name="blahblah"
android:description="@string/app_desc">

<activity android:label="@string/app_name" android:name=".activities.MainMenu">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<activity android:name=".activities.FullList" android:label="@string/app_name"/>

<!-- The application's publisher ID assigned by AdMob -->
<meta-data android:value="blahblahblah" android:name="ADMOB_PUBLISHER_ID" />

</application>
<uses-sdk android:minSdkVersion="4"/>

<uses-permission android:name="android.permission.INTERNET"></uses-permission>

</manifest>

我试过从头开始创建一个新项目,只有一个使用 Jsoup.connect() 方法的 hello world 屏幕,并且在同一个 1.6 模拟器上工作正常,所以它一定是代码问题,但我做不到弄清楚。

最佳答案

JSOUP 内部使用 HttpURLConnection .这是 line throwing exception .

互联网连接正常(否则它会提前抛出异常)并且您从服务器收到回复:403 HTTP FORBIDDEN

是否有某种登录方式?请检查您是否可以在同一设备/模拟器上的浏览器中打开相同的 URL。

关于android - Internet Access 不适用于 Android 1.6,但适用于 2.0/2.1/2.2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4219211/

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