Created
July 30, 2016 05:21
-
-
Save developer--/ef632d8a7c9670697bb1e527655eb314 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment