Android 5.1 и 6 FileNotFoundException при обращении к URL хорошо работают на Android 7,8,9 - PullRequest
0 голосов
/ 11 марта 2020
URL url = new URL("https://urdufatwa.com/api/search?search_tag=قرب&page=1&perPage=15");
            connection = (HttpURLConnection) url.openConnection();
            connection.connect();
            InputStream stream = connection.getInputStream();
            reader = new BufferedReader(new InputStreamReader(stream));
            StringBuffer buffer = new StringBuffer();
            String line = "";

            while ((line = reader.readLine()) != null) {
                buffer.append(line+"\n");
                Log.d("Response: ", "> " + line);
            }
            String str =  buffer.toString();
            JSONObject json = new JSONObject(str);

исключение составляет

java .io.FileNotFoundException: https://urdufatwa.com/api/search?search_tag=قرب&page=1&perPage=15

...