我的 android 应用程序在某些设备中获得 StringIndexOutOfBound 异常,并且在某些设备中也可以正常工作
这是我的代码
try {
Document document = Jsoup.connect(PostLink).header("Accept-Encoding", "gzip, deflate").userAgent("Mozilla/5.0 (Windows NT 6.1; WOW64; rv:23.0) Gecko/20100101 Firefox/23.0").get();
String FullPage = document.toString();
int startIndex = FullPage.indexOf("//");
int endIndex = FullPage.indexOf("?", startIndex);
String DownloadableLink = FullPage.substring(startIndex, endIndex);
Log.i("URLFETCH", DownloadableLink);
if (DownloadableLink.length() > 0 && DownloadableLink.startsWith("//m") && DownloadableLink.endsWith(".mp4")) {
return new basic(Name, PostLink, document.title(), "https:" + DownloadableLink);
} else {
DatabaseReference reference = FirebaseDatabase.getInstance().getReference();
reference.child("Errored").push().setValue(new basic(Name, PostLink, document.title(), "https:" + DownloadableLink));
}
} catch (IOException e) {
e.printStackTrace();
}
这就是我在“doinbackground”方法中的“AsyncTask”中所做的,所以我还让 DB ref 获取信息以了解其原因或导致我的应用程序崩溃的 URL 类型。