0

Very recently, I started getting the following error back from my widget. I didn't make any changes and I'm wondering what the problem could be and how to get around the problem. My widget gets updated based on information from a Service that I created to access information from a third-party client. I was able to get the data back fine until a few days ago. Now I receive the error below.

I've just tried to run the code in an activity (i.e., a non-widget) and it works fine. I'm not sure why it works in an activity but not a widget. I'm also running the access to the 3rd party website in a separate Intent.

I have tried restarting the emulator, eclipse and rebooting the device. My manifest file has the proper permissions to access the Internet. The problem initially seemed to be a network issue but I confirmed that I could access the URL from the web browser on the emulator and the device. The code was just working a couple of days ago. I have updated the post with my manifest file. The code fails right before the call to parseMyInfo. An exception is thrown during the OAuth consumer/provider calls.

Error

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)

Failing Code The code that's failing is below:

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);

Manifest file

<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>
user836200
  • 655
  • 2
  • 12
  • 20
  • 1
    `UnknowHostException` usually means your DNS system was unable to resolve the hostname. – asgs Aug 25 '11 at 14:30
  • 1
    not sure why this was downvoted. I upvoted you back up. Probably due to the look before The Elite Gentleman's edit. :) And asgs is correct, I would double check that you have internet permissions enabled, that would be my first step. – Codeman Aug 25 '11 at 14:34
  • Are you absolutely sure that your permissions are correct in your manifest.xml? Can you add it to your original post? – Eric Levine Aug 25 '11 at 14:36
  • Yes, I have the Internet permissions set (I added my manifest file to the post). – user836200 Aug 25 '11 at 21:13

3 Answers3

1

The website "communitymonitorstudy.stepgreen.org" is up and running, I have checked that a minute ago.

So

  • either the problem has disappeared on your side as well (please double check) if the site was down before

  • or you are experiencing network issues preventing the host to be found.

You should check with a regular browser hosted on the same device whether you can access to the website. If so, this means that the problem is tied to the application. If not, it pertains to the network connection.

The code you have sent is not complete: we don't know how client is used by parseMyInfo(). Please update your question with some more code should the problem be tied to your application further to the test I have suggested above.

Shlublu
  • 10,917
  • 4
  • 51
  • 70
  • I've double checked that I can access the website and duplicate the problem on both the emulator and the system. ParseMyInfo is never called - the code crashes before it can reach that line.and the problem still exists. – user836200 Aug 25 '11 at 21:12
1

I can't believe my mistake...

Those of you who said I had an issue with my permissions were right. I needed to include my Internet permission outside of the application. IE:

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

<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>

</manifest>
user836200
  • 655
  • 2
  • 12
  • 20
0

I had the exact same issue a week ago on two of my devices (a Nexus One on 2.3.4 and a Transformer on 3.1). Thought it was my code, so installed an older version and nope, same error.

The solution? A reboot for each. Assuming something must be awry in the OS somewhere.

Dave
  • 6,064
  • 4
  • 31
  • 38