作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试在我的 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/
我是一名优秀的程序员,十分优秀!