Commit 58d12511 authored by jyx's avatar jyx

优化bugly空指针问题

parent 2d499c64
......@@ -264,10 +264,6 @@ class ScreenLockerObserver(private val context: Context) {
if (IntentUtils.isRunningForeground(context) && ForegroundOrBackground.getApp_activity() != null) {
ForegroundOrBackground.getApp_activity().moveTaskToBack(true)
}
// val activity = context as Activity
// if (activity !is ScreenActivity) {
// activity.moveTaskToBack(true)
// }
try {
BrandEventLogger.logEventWithBrand(
......
......@@ -29,7 +29,6 @@ public class ForegroundOrBackground implements Application.ActivityLifecycleCall
//获取当前最上层的activity
private static WeakReference<Activity> app_activity;
private static WeakReference<Activity> main_activity;
private static WeakReference<Activity> trans_activity;
private WeakReference<VersionUpdatePresenter> vupWeakReference;
private VersionUpdatePresenter vup;
private WeakReference<Activity> reference;
......@@ -62,10 +61,10 @@ public class ForegroundOrBackground implements Application.ActivityLifecycleCall
public static Activity getMain_activity() {
try {
if (main_activity.get() != null) {
if (main_activity != null && main_activity.get() != null) {
return main_activity.get();
}
return app_activity.get();
return null;
} catch (NullPointerException e) {
e.printStackTrace();
return null;
......@@ -74,10 +73,10 @@ public class ForegroundOrBackground implements Application.ActivityLifecycleCall
public static Activity getApp_activity() {
try {
if (app_activity.get() != null) {
if (app_activity != null && app_activity.get() != null) {
return app_activity.get();
}
return main_activity.get();
return getMain_activity();
} catch (NullPointerException e) {
e.printStackTrace();
return null;
......@@ -136,10 +135,6 @@ public class ForegroundOrBackground implements Application.ActivityLifecycleCall
if (TextUtils.equals(activity.getClass().getSimpleName(), "MainActivity")) {
main_activity = new WeakReference<>(activity);
}
if (TextUtils.equals(activity.getClass().getSimpleName(), "TransPlaceActivity")) {
trans_activity = new WeakReference<>(activity);
}
}
@Override
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment