Chromium Code Reviews| Index: ui/android/java/src/org/chromium/ui/base/ActivityWindowAndroid.java |
| diff --git a/ui/android/java/src/org/chromium/ui/base/ActivityWindowAndroid.java b/ui/android/java/src/org/chromium/ui/base/ActivityWindowAndroid.java |
| index b32cd9b95a81e997d40cc3593ac3871d4a3f1cf8..676e8d6999e4231be757a2f0bdbcdb65e9745ae2 100644 |
| --- a/ui/android/java/src/org/chromium/ui/base/ActivityWindowAndroid.java |
| +++ b/ui/android/java/src/org/chromium/ui/base/ActivityWindowAndroid.java |
| @@ -10,6 +10,9 @@ import android.content.ActivityNotFoundException; |
| import android.content.Intent; |
| import android.content.IntentSender.SendIntentException; |
| +import org.chromium.base.ActivityState; |
| +import org.chromium.base.ApplicationStatus; |
| + |
| import java.lang.ref.WeakReference; |
| /** |
| @@ -17,7 +20,8 @@ import java.lang.ref.WeakReference; |
| * Activity Instance. |
| * Only instantiate this class when you need the implemented features. |
| */ |
| -public class ActivityWindowAndroid extends WindowAndroid { |
| +public class ActivityWindowAndroid extends WindowAndroid |
| + implements ApplicationStatus.ActivityStateListener { |
|
no sievers
2015/03/17 21:37:47
There is also a native interface in base/android/a
jdduke (slow)
2015/03/17 22:22:17
Hmm, I didn't see that, though it looks like that
|
| // Constants used for intent request code bounding. |
| private static final int REQUEST_CODE_PREFIX = 1000; |
| private static final int REQUEST_CODE_RANGE_SIZE = 100; |
| @@ -29,6 +33,7 @@ public class ActivityWindowAndroid extends WindowAndroid { |
| public ActivityWindowAndroid(Activity activity) { |
| super(activity.getApplicationContext()); |
| mActivityRef = new WeakReference<Activity>(activity); |
| + ApplicationStatus.registerStateListenerForActivity(this, activity); |
| } |
| @Override |
| @@ -99,6 +104,14 @@ public class ActivityWindowAndroid extends WindowAndroid { |
| return new WeakReference<Activity>(mActivityRef.get()); |
| } |
| + @Override |
| + public void onActivityStateChange(Activity activity, int newState) { |
| + if (newState == ActivityState.PAUSED) |
| + onActivityPaused(); |
| + else if (newState == ActivityState.RESUMED) |
| + onActivityResumed(); |
| + } |
| + |
| private int generateNextRequestCode() { |
| int requestCode = REQUEST_CODE_PREFIX + mNextRequestCode; |
| mNextRequestCode = (mNextRequestCode + 1) % REQUEST_CODE_RANGE_SIZE; |