Before answer or taking any action just by seeing the question title please read description carefully, I am trying to do this yesterday and today a full day and night but I couldn't find any acceptable solution. Some are deprecated from android some are not working, some are just checking internet is just connected or not. But that's not what I am asking for.
I have applied many Stack Overflow answers in this regard but nothing is working perfectly. The functionality I am asking for is,
say MathActivity.java and activity_math.xml is a page loaded after clicking a button from mainActivity.java. When  MathActivity.java is starting after clicking the button its primarily can check active internet connection via the ping method. Though its not working properly,
public boolean checkIntCON() {
        try {
            Process ipProcess = Runtime.getRuntime().exec("/system/bin/ping -c 1 8.8.8.8");
            return (ipProcess.waitFor() == 0);
        }
        catch (IOException e)          { e.printStackTrace(); }
        catch (InterruptedException e) { e.printStackTrace(); }
        return false;
    }
But its check just one time when I am entering [I did that work but I don't want that], say user is reading a pdf in activity_math.xml and when user reading this user turned off internet connection, I am also able to listen that functionality when user turn off connection this would be ok but if user again turn on data with internet unavailability then I can't listen this .
I want to get recent and maximum device supported solution to check in continues internet connection. say user is reading a pdf, after five minutes I want to check if the user have an active internet connection or not. Connection should be must transferrable internet connection. I have found AsyncTask solution but its deprecated. The main focus is I want to check user active internet connection after a certain interval.
Here is an image to explain more,

Is there any solution? If any please try to give me in detail code that i just want to copy and paste in project. I have visited all in stack overflow again I am mentioning.
 
    