我需要检测 Activity 或 BroadcastReceiver 是否启动应用程序 - 在 Application.onCreate 方法内部。如果应用程序是由广播接收器启动的,则不应调用 tryLoginOffline()
。
public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
if(calledByActivity) {
tryLoginOffline();
}
}
//...
}
谢谢!
最佳答案
I need to detect if Activity or BroadcastReceiver starts the application - inside of Application.onCreate method.
抱歉,但没有选择。
Call tryLoginOffline() should not be in case of the application is started by broadcast receiver.
那么该代码不应位于 Application
子类的 onCreate()
方法中。从您的 Activity 中调用它。
关于java - 在 Android Application.onCreate() 方法中检测 Activity/BroadcastReceiver,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54707825/