robert.little
robert.little

Reputation: 410

Detect Activity/BroadcastReceiver in Android Application.onCreate() method

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.

public class MyApplication extends Application {

    @Override
    public void onCreate() {
        super.onCreate();

        if(calledByActivity) {
            tryLoginOffline();
        }
    }
    //...
}

Thanks!

Upvotes: 1

Views: 83

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006584

I need to detect if Activity or BroadcastReceiver starts the application - inside of Application.onCreate method.

Sorry, but there is no option for that.

Call tryLoginOffline() should not be in case of the application is started by broadcast receiver.

Then that code should not be in an Application subclass' onCreate() method. Call it from your activity.

Upvotes: 3

Related Questions