public class MyApplication extends Application implements ActivityLifecycleCallbacks { private static boolean isInterestingActivityVisible; @Override public void onCreate() { super.onCreate(); // Register to be notified of activity state changes registerActivityLifecycleCallbacks(this); .... } public boolean isInterestingActivityVisible() { return isInterestingActivityVisible; } @Override public void onActivityResumed(Activity activity) { if (activity instanceof MyInterestingActivity) { isInterestingActivityVisible = true; } } @Override public void onActivityStopped(Activity activity) { if (activity instanceof MyInterestingActivity) { isInterestingActivityVisible = false; } } // Other state change callback stubs ....} <application android:name="your.app.package.MyApplication" android:icon="@drawable/icon" android:label="@string/app_name" >@Overrideprotected void onResume() { super.onResume(); MyApplication.activityResumed();}@Overrideprotected void onPause() { super.onPause(); MyApplication.activityPaused();}在您的finish()方法中,您想使用isActivityVisible()来检查活动是否可见.您还可以在此处检查用户是否选择了一个选项.当两个条件都满足时,继续.In your finish() method, you want to use isActivityVisible() to check if the activity is visible or not. There you can also check if the user has selected an option or not. Continue when both conditions are met. 这篇关于PagerAdapter通过通知更改了适配器的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!