Get value from JSON and put it in String
<p>it's my first question here, i've try to be the more explicit :)</p>

<p>I want get value from a <code>JSON</code> page : <a href="https://api.dailymotion.com/video/x3p6d9r?fields=onair" rel="nofollow">https://api.dailymotion.com/video/x3p6d9r?fields=onair</a>.</p>

<p>I have follow a tutorial about <code>json object</code>. </p>

<p>But i want get the value <code>"onair"</code> and put this in a <code>String</code> for use a <code>IF STRING == "XX"</code>.</p>

<p>This is my code :</p>

<pre><code>public class notification extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_notification);

        detectonline();

    }

    public void detectonline(){
        /*
        if (xx == "false") {
             Do something is live is off
        }
        else{
           Do something is live is on
        }

         */

    }

    public static boolean checkIfOnline(String channel) throws IOException {
        String channerUrl = "https://api.dailymotion.com/video/x3p6d9r?fields=onair";

        String jsonText = readFromUrl(channerUrl);// reads text from URL

        JsonParser parser = new JsonParser();
        JsonObject json = parser.parse(jsonText).getAsJsonObject();

        return !json.get("onair").isJsonNull();
    }

    private static String readFromUrl(String url) throws IOException {
        URL page = new URL(url);
        StringBuilder sb = new StringBuilder();
        Scanner scanner = null;
        try{
            //scanner = new Scanner(page.openStream(), StandardCharsets.UTF_8.name());
            scanner = new Scanner(page.openStream());
            while (scanner.hasNextLine()){
                sb.append(scanner.nextLine());
            }
        }finally{
            if (scanner!=null)
                scanner.close();
        }
        return sb.toString();
    }
}
</code></pre>