jeudi 3 mai 2018

string index out of bound android in doInBackgroun

i need a little help please any one guide , my android app gets StringIndexOutOfBound exceptions in some devices and also works 1000% perfectly in some devices

here is my code where i am facing

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();
            **strong textint 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();
        }

the bold text is where error couses.

this i am doing in my 'AsyncTask' in 'doinbackground' method, so i also make DB ref to get information to know about why its causing or on which type of URL being causes my app to crashed.any help will be very very appreciated thanks :)

Aucun commentaire:

Enregistrer un commentaire