Catch ActivityNotFoundException to prevent crash.

This problem occurred with some podcasts using embedded youtube videos. In these cases, the 'http:"-part of the URL was missing and therefore, no activity for viewing the URL was found.
This commit is contained in:
daniel oeh 2013-08-17 17:18:12 +02:00
parent 462ff3cadc
commit 7c4715128c

View File

@ -1,5 +1,6 @@
package de.danoeh.antennapod.fragment;
import android.content.*;
import android.support.v4.app.Fragment;
import android.support.v7.app.ActionBarActivity;
import de.danoeh.antennapod.feed.FeedItem;
@ -9,10 +10,6 @@ import org.apache.commons.lang3.StringEscapeUtils;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.ClipData;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.TypedArray;
import android.net.Uri;
import android.os.AsyncTask;
@ -117,7 +114,12 @@ public class ItemDescriptionFragment extends Fragment {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(intent);
try {
startActivity(intent);
} catch (ActivityNotFoundException e) {
e.printStackTrace();
return false;
}
return true;
}
@ -138,6 +140,7 @@ public class ItemDescriptionFragment extends Fragment {
}
});
registerForContextMenu(webvDescription);
return webvDescription;
}