1

In my Android app I'll get the source of a html page. That's my Code: http://pastebin.com/FJyWhVrL It shows me every time by getHtml(); an Unhandled exception type IOException and Unhandled exception type ClientProtocolException. In the manifest file I've set the permission it looks like this:

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

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" >
    <activity
        android:name=".DownloadsActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

Can someone help me?

Thank you

Mogsdad
  • 44,709
  • 21
  • 151
  • 275
  • 2
    possible duplicate of [unhandled exception type error](http://stackoverflow.com/questions/5162587/unhandled-exception-type-error) – Thilo Jun 14 '12 at 12:03

1 Answers1

1

Those are compile errors. You are calling getHtml, which can throw these two exceptions.

So you need to catch them in your code and do something about it.

button.setOnClickListener(new OnClickListener() {
           public void onClick(View v) {
                try {
                  getHtml();
                }
                catch (IOException e){
                   // do something
                }
                catch (ClientProtocolException e){
                   // do something
                }

           }
        });
Thilo
  • 257,207
  • 101
  • 511
  • 656