Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class BaseActivity extends AppCompatActivity {
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- }
- public static boolean isAppInFg = false;
- public static boolean isScrInFg = false;
- public static boolean isChangeScrFg = false;
- @Override
- protected void onStart() {
- if (!isAppInFg) {
- isAppInFg = true;
- isChangeScrFg = false;
- onAppStart();
- } else {
- isChangeScrFg = true;
- }
- isScrInFg = true;
- super.onStart();
- }
- @Override
- protected void onStop() {
- super.onStop();
- if (!isScrInFg || !isChangeScrFg) {
- isAppInFg = false;
- onAppPause();
- }
- isScrInFg = false;
- }
- private void onAppStart() {
- AlarmReceiver.stopAlarmService(this);
- // Toast.makeText(getApplicationContext(), "App in foreground", Toast.LENGTH_LONG).show();
- }
- private void onAppPause() {
- AlarmReceiver.startLocalNotificationService(this);
- // Toast.makeText(getApplicationContext(), "App in background", Toast.LENGTH_LONG).show();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement