Posted on Leave a comment

Android Code : Ping a domain/IP & Latency Calculation

The following code may be used to ping the IP / Domain addresses and to obtain latency

Tested in Android 4.4.2, 6.0
Mobile handsets: Lenovo A6000, Redmi Note 4A
Working application: PUBG Network Quality Check
Minimum API Tested: 19

public long pingg (String domain){
        Runtime runtime = Runtime.getRuntime();
        try {
            long a = (System.currentTimeMillis() % 100000);
            Process ipProcess = runtime.exec("/system/bin/ping -c 1 "+domain);
            long b = (System.currentTimeMillis() % 100000);
            if (b <= a) {
                timeofping = ((100000 - a) + b);
            } else {
                timeofping = (b - a);
        }catch (Exception e){

        return timeofping;

The code fetches the current time in milliseconds to a variable.
The ping function is then called, with the domain as the parameter.
The code waits till the pinging is over.
The current time in milliseconds is fetched again.
The time interval between this is calculated as latency.

Special Thanks to StackOverflow for the idea and code concept !

Posted on Leave a comment

Announcing Introduction of Knowledge Centers

Dear well-wishers and followers,

We are glad to announce the introduction of ‘Knowledge centers’. When we were working on our android project, we came across a few obstacles in coding. Apart from the normal coding practices and logic, we came across a few libraries and repositories which could be of help.

Knowledge center was selected on the basis of polls in our Facebook Group – where most people chose that the knowledge and lessons learnt are to be made available for the people who follow us.

We will soon be introducing the Knowledge Center on our home page. This will be in the blog, but categorized separately, with home page featuring the link to the knowledge center.

Knowledge center may be found at

Stay tuned for the updates !

The Team,
RegalDream Technologies