platform/android/Rhodes/src/com/rhomobile/rhodes/Rhodes.java in rhodes-2.0.2 vs platform/android/Rhodes/src/com/rhomobile/rhodes/Rhodes.java in rhodes-2.0.3

- old
+ new

@@ -39,10 +39,11 @@ import com.rhomobile.rhodes.uri.UriHandler; import com.rhomobile.rhodes.uri.VideoUriHandler; import android.app.Activity; import android.content.Context; +import android.content.Intent; import android.content.pm.ActivityInfo; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager.NameNotFoundException; import android.content.res.Configuration; import android.graphics.Bitmap; @@ -82,14 +83,16 @@ public static final int RHO_TOOLBAR_VIEW = 3; public static int WINDOW_FLAGS = WindowManager.LayoutParams.FLAG_FULLSCREEN; public static int WINDOW_MASK = WindowManager.LayoutParams.FLAG_FULLSCREEN; - private static int MAX_PROGRESS = 10000; + public static int MAX_PROGRESS = 10000; - private static boolean ENABLE_LOADING_INDICATION = true; + public static boolean ENABLE_LOADING_INDICATION = true; + private static boolean ownActivityActivated; + private boolean needGeoLocationRestart = false; private long uiThreadId; public long getUiThreadId() { return uiThreadId; @@ -479,13 +482,14 @@ /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + + // Here Log should be used, not Logger. It is because Logger is not initialized yet. + Log.v(TAG, "+++ onCreate"); - Logger.T(TAG, "+++ onCreate"); - Thread ct = Thread.currentThread(); ct.setPriority(Thread.MAX_PRIORITY); uiThreadId = ct.getId(); RhodesInstance.setInstance(this); @@ -569,17 +573,20 @@ @Override protected void onStart() { super.onStart(); Logger.T(TAG, "+++ onStart"); + ownActivityActivated = false; + if (needGeoLocationRestart) { + GeoLocation.isKnownPosition(); + needGeoLocationRestart = false; + } } @Override protected void onResume() { super.onResume(); - if (needGeoLocationRestart) - GeoLocation.isKnownPosition(); Logger.T(TAG, "+++ onResume"); } @Override protected void onPause() { @@ -590,10 +597,12 @@ @Override protected void onStop() { Logger.T(TAG, "+++ onStop"); needGeoLocationRestart = GeoLocation.isAvailable(); GeoLocation.stop(); + if (!ownActivityActivated) + stopSelf(); super.onStop(); } @Override protected void onDestroy() { @@ -761,9 +770,15 @@ } private void stopSelf() { //stopRhodesApp(); Process.killProcess(Process.myPid()); + } + + @Override + public void startActivity(Intent intent) { + ownActivityActivated = true; + super.startActivity(intent); } static { NativeLibraries.load(); }