gpt4 book ai didi

java - 未知主机异常

转载 作者:行者123 更新时间:2023-12-02 08:12:10 24 4
gpt4 key购买 nike

最近,我开始从我的小部件返回以下错误。我没有做任何改变,我想知道问题可能是什么以及如何解决这个问题。我的小部件根据我创建的用于访问第三方客户端信息的服务中的信息进行更新。直到几天前我才能够正常恢复数据。现在我收到以下错误。

我刚刚尝试在 Activity (即非小部件)中运行代码,它工作正常。我不确定为什么它在 Activity 中起作用,但在小部件中不起作用。我还在单独的 Intent 中运行对第 3 方网站的访问。

我尝试过重新启动模拟器、Eclipse 并重新启动设备。我的 list 文件具有访问互联网的适当权限。该问题最初似乎是网络问题,但我确认可以从模拟器和设备上的网络浏览器访问该 URL。该代码几天前才起作用。我已经用我的 list 文件更新了该帖子。该代码在调用 parseMyInfo 之前失败。 OAuth 消费者/提供者调用期间抛出异常。

错误

oauth.signpost.AbstractOAuthProvider.retrieveToken(AbstractOAuthProvider.java:214)
08-24 22:36:02.063: ERROR/ARCHOS(541): at oauth.signpost.AbstractOAuthProvider.retrieveRequestToken(AbstractOAuthProvider.java:69)
08-24 22:36:02.063: ERROR/ARCHOS(541): at com.test.community.SG_Service$TED.populate(SG_Service.java:276)
08-24 22:36:02.063: ERROR/ARCHOS(541): at com.test.community.SG_Service$SGHandler.getTEDData(SG_Service.java:813)
08-24 22:36:02.063: ERROR/ARCHOS(541): at com.test.community.SG_Service$SGService_BG.onHandleIntent(SG_Service.java:844)
08-24 22:36:02.063: ERROR/ARCHOS(541): at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:59)
08-24 22:36:02.063: ERROR/ARCHOS(541): at android.os.Handler.dispatchMessage(Handler.java:99)
08-24 22:36:02.063: ERROR/ARCHOS(541): at android.os.Looper.loop(Looper.java:123)
08-24 22:36:02.063: ERROR/ARCHOS(541): at android.os.HandlerThread.run(HandlerThread.java:60)
08-24 22:36:02.063: ERROR/ARCHOS(541): Caused by: java.net.UnknownHostException: communitymonitorstudy.stepgreen.org
08-24 22:36:02.063: ERROR/ARCHOS(541): at java.net.InetAddress.lookupHostByName(InetAddress.java:513)
08-24 22:36:02.063: ERROR/ARCHOS(541): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:278)
08-24 22:36:02.063: ERROR/ARCHOS(541): at java.net.InetAddress.getAllByName(InetAddress.java:242)
08-24 22:36:02.063: ERROR/ARCHOS(541): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:136)
08-24 22:36:02.063: ERROR/ARCHOS(541): at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
08-24 22:36:02.063: ERROR/ARCHOS(541): at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
08-24 22:36:02.063: ERROR/ARCHOS(541): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:348)
08-24 22:36:02.063: ERROR/ARCHOS(541): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
08-24 22:36:02.063: ERROR/ARCHOS(541): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
08-24 22:36:02.063: ERROR/ARCHOS(541): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
08-24 22:36:02.063: ERROR/ARCHOS(541): at oauth.signpost.commonshttp.CommonsHttpOAuthProvider.sendRequest(CommonsHttpOAuthProvider.java:64)
08-24 22:36:02.063: ERROR/ARCHOS(541): at oauth.signpost.AbstractOAuthProvider.retrieveToken(AbstractOAuthProvider.java:177)

失败代码失败的代码如下:

HttpClient client = new DefaultHttpClient();

consumer = new CommonsHttpOAuthConsumer(Constants.CONSUMER_KEY,
Constants.CONSUMER_SECRET);
provider = new CommonsHttpOAuthProvider(Constants.REQUEST_TOKEN_URL,
Constants.ACCESS_TOKEN_URL, Constants.AUTHORIZE_URL, client);

provider.retrieveRequestToken(consumer, OAuth.OUT_OF_BAND);

provider.retrieveAccessToken(consumer, null);

MyInfo info = parseMyInfo(userName, consumer, client);

list 文件

<application android:icon="@drawable/icon" android:debuggable="true"  
android:label="@string/app_name" android:name="AppStatus">

<activity android:name=".CommunityMonitorActivity"android:label="@string/app_name">
<intent-filter>
<action android:name="com.cmu.community.CommunityWidget.ACTION_WIDGET_CONFIGURE"/>
</intent-filter>
</activity>

<activity android:name=".MyInfoActivity"
android:theme="@style/Theme.D1"
android:label="@string/my_info"
/>

<activity android:name=".HomeActivity"
android:theme="@style/Theme.D1"
android:label="@string/home"
/>

<activity android:name=".AboutActivity"
android:theme="@style/Theme.D1"
android:label="@string/about"
/>


<receiver android:name=".CommunityWidget" android:label="@string/app_name">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />

<action android:name="com.cmu.community.CommunityWidget.ACTION_WIDGET_RECEIVER"/>
</intent-filter>
<meta-data android:name="android.appwidget.provider"
android:resource="@xml/communitywidgetprovider" />
</receiver>

<receiver android:name="com.cmu.community.Stepgreen_Service$StepgreenReceiver">
<intent-filter>
<action android:name="com.cmu.community.ACTION_STEPGREENMANAGER"></action>
</intent-filter>
</receiver>

<receiver android:name="com.cmu.community.AppStatus_Service$AppStatusReceiver">
<intent-filter>
<action android:name="com.cmu.community.ACTION_APPSTATUSMANAGER"></action>
</intent-filter>
</receiver>


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

<service android:name="Stepgreen_Service$StepgreenService_BG"></service>
</application>
</manifest>

最佳答案

网站“communitymonitorstudy.stepgreen.org”已启动并运行,我一分钟前已检查过。

所以

  • 如果网站之前已关闭,问题也可能在您这边消失了(请仔细检查)

  • 或者您遇到网络问题,无法找到主机。

您应该使用同一设备上托管的常规浏览器检查是否可以访问该网站。如果是这样,则意味着问题与应用程序有关。如果不是,则与网络连接有关。

您发送的代码不完整:我们不知道parseMyInfo()如何使用client。如果问题与您的应用程序进一步关联到我上面建议的测试,请使用更多代码更新您的问题。

关于java - 未知主机异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7192108/

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