mobile: prevent force close in onStop() method on devices without mobile
data connection module
This commit is contained in:
parent
0d51e045a0
commit
886c56da94
@ -1,8 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="com.cradle.iitc_mobile"
|
package="com.cradle.iitc_mobile"
|
||||||
android:versionCode="7"
|
android:versionCode="8"
|
||||||
android:versionName="0.2.6" >
|
android:versionName="0.2.7" >
|
||||||
|
|
||||||
<uses-sdk
|
<uses-sdk
|
||||||
android:minSdkVersion="14"
|
android:minSdkVersion="14"
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
<string name="about">About</string>
|
<string name="about">About</string>
|
||||||
|
|
||||||
<string name="pref_about_title">About IITC Mobile</string>
|
<string name="pref_about_title">About IITC Mobile</string>
|
||||||
<!-- Use CDATA to prevent android from parsin html tags....we are doing this with Html.fromHtml() -->
|
<!-- Use CDATA to prevent android from parsing html tags....we are doing this with Html.fromHtml() -->
|
||||||
<string name="pref_about_msg">
|
<string name="pref_about_msg">
|
||||||
<![CDATA[<big><b>Ingress Intel Total Conversion Mobile</b></big><br><br>
|
<![CDATA[<big><b>Ingress Intel Total Conversion Mobile</b></big><br><br>
|
||||||
<b>by <a href="https://github.com/leCradle">cradle</a></b><br><br>
|
<b>by <a href="https://github.com/leCradle">cradle</a></b><br><br>
|
||||||
|
@ -6,7 +6,6 @@ import com.cradle.iitc_mobile.R;
|
|||||||
|
|
||||||
import android.net.ConnectivityManager;
|
import android.net.ConnectivityManager;
|
||||||
import android.net.NetworkInfo;
|
import android.net.NetworkInfo;
|
||||||
import android.net.NetworkInfo.State;
|
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
@ -85,17 +84,29 @@ public class IITC_Mobile extends Activity {
|
|||||||
protected void onStop() {
|
protected void onStop() {
|
||||||
ConnectivityManager conMan = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
|
ConnectivityManager conMan = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||||
|
|
||||||
State mobile = conMan.getNetworkInfo(0).getState();
|
NetworkInfo mobile = conMan.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
|
||||||
State wifi = conMan.getNetworkInfo(1).getState();
|
NetworkInfo wifi = conMan.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
|
||||||
|
|
||||||
if (mobile == NetworkInfo.State.CONNECTED || mobile == NetworkInfo.State.CONNECTING) {
|
// check if Mobile or Wifi module is available..then handle states
|
||||||
// cancel all current requests
|
// TODO: theory...we do not have to check for a Wifi module...every android device should have one
|
||||||
iitc_view.loadUrl("javascript: window.requests.abort()");
|
if (mobile != null) {
|
||||||
// set idletime to maximum...no need for more
|
Log.d("iitcm", "mobile internet module detected...check states");
|
||||||
iitc_view.loadUrl("javascript: window.idleTime = 999");
|
if (mobile.getState() == NetworkInfo.State.CONNECTED || mobile.getState() == NetworkInfo.State.CONNECTING) {
|
||||||
} else if (wifi == NetworkInfo.State.CONNECTED || wifi == NetworkInfo.State.CONNECTING) {
|
Log.d("iitcm", "connected to mobile net...abort all running requests");
|
||||||
iitc_view.loadUrl("javascript: window.idleTime = 999");
|
// cancel all current requests
|
||||||
|
iitc_view.loadUrl("javascript: window.requests.abort()");
|
||||||
|
// set idletime to maximum...no need for more
|
||||||
|
iitc_view.loadUrl("javascript: window.idleTime = 999");
|
||||||
|
} else if (wifi.getState() == NetworkInfo.State.CONNECTED || wifi.getState() == NetworkInfo.State.CONNECTING) {
|
||||||
|
iitc_view.loadUrl("javascript: window.idleTime = 999");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Log.d("iitcm", "no mobile internet module detected...check wifi state");
|
||||||
|
if (wifi.getState() == NetworkInfo.State.CONNECTED || wifi.getState() == NetworkInfo.State.CONNECTING) {
|
||||||
|
iitc_view.loadUrl("javascript: window.idleTime = 999");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Log.d("iitcm", "stopping iitcm");
|
||||||
super.onStop();
|
super.onStop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user