I have an app that has an alarmlistener that returns position and send it to a server, but firts it checks the internet connection. This is the method that checks the connection:
public boolean hasInternetConnection() {
ConnectivityManager connectivityManager = (ConnectivityManager) context
.getSystemService(Context.CONNECTIVITY_SERVICE);
if (connectivityManager != null) {
NetworkInfo networkInfo = connectivityManager
.getActiveNetworkInfo();
if (networkInfo != null && networkInfo.isAvailable()
&& networkInfo.isConnected()) {
return true;
} else {
return false;
}
} else {
return false;
}
}
Permissions on the Manifest:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="pe.com.hacom.taxitrack.mgr.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.BATTERY_STATS" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
And it has been working fine, but when I tried it on a Motorola XT316 it didn't work, it always return false, even when the device has connection, I check it openning the internet browser and it shows the webpage normally, but the alarm still returning false with that method.
I tested it in other devices and it works fine with all, but that Motorola, any idea what is happening? is that a hardware bug?
And the most rare thing is that sometimes I can get the device in DDMS for the logs on the debug but almost always it appears "Offline". I have installed the driver that is in the device, also uninstalling it and installing the universal driver of motorola from the webpage, and its working with Motoroal RAZR's but not with the XT316.
This might be happening because the device have some sort of battery management system, which disables internet connection, and enables it when you open the browser, but it doesn't work when this Alarm is triggered.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With