Here is the code to see if my Android has an Internet connection. I want to know if there is any method to count the Bytes, Kylobytes that are entering my application; obviously not going to download anything just want me to pull the megabytes like a meter or accumulator.
public void conexion2(){
ConnectivityManager cm;
NetworkInfo ni;
cm = (ConnectivityManager) this.getSystemService(Context.CONNECTIVITY_SERVICE);
ni = cm.getActiveNetworkInfo();
boolean tipoConexion1 = false;
if (ni != null) {
ConnectivityManager connManager1 = (ConnectivityManager)this.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo mWifi = connManager1.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
if (mWifi.isConnected()) {
tipoConexion1 = true;
Toast.makeText(this, "Red wifi encontrada", Toast.LENGTH_LONG).show();
dp.setProgress(100);
}
}
else {
Toast.makeText(this, "NO Hay conexion", Toast.LENGTH_LONG).show();
}
}