When saying "app shortcuts", I mean this: https://developer.android.com/guide/topics/ui/shortcuts.html
My app has following flow:
- Start SplashActiviy and do some required initializations (like check if Google Play Services is available etc).
From SplashActivity, start LoginActivity, this way:
@Override protected void onCreate(Bundle savedInstanceState) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) requestWindowFeature(Window.FEATURE_CONTENT_TRANSITIONS); super.onCreate(savedInstanceState); if(checkPlayServices()==false) { return; } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { getWindow().setExitTransition(new Fade()); } Intent intent = new Intent(this, LoginActivity.class); ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(this); ActivityCompat.startActivity(this, intent, options.toBundle()); ActivityCompat.finishAfterTransition(this); } }
Then my LoginActivity is launched. LoginActvity handles user login via Firebase - user is able to choose login with Google, Facebook or email. After succesful login to Firebase, my app calls rest webservice to get access tokens from my server, then it starts MainActivity and passess access tokens to it. There is also FirebaseAuth.AuthStateListener
used to handle auto login on app launch (until user logs out), without asking for any credentials. MainActivity has some flow too, it performs some operations, then it allows to choose what do display, from navigation drawer menu. There are some actions required to do by users, it depends if app is launched first time (force to select city from list, cities list loaded from backend).
Now I need to develop static app shourtcuts with intents for:
- Events list (this is default behaviour, after users sign in and choose city if there is no city chosen - first run, or load data from city used previously)
- Messages list - user need to choose corresponding menu option to load messages list (it causes rest webservice calls to load messages)
I'm stuck, because I have no idea how to implement intent to preserve all required steps. I can't just declare intent to launch MainActivity, it won't work because this will cause to launch MainActivity immediately, without any required initialization, get access tokens etc.
Any tips?
Ok, so I managed it by set action for each intent, then populate action name to decide, which option should be launched. I think it's simplest solution