activity to dispatch or redirect to other activities
I want to create a dispatcher activity, defined with android.intent.action.MAIN
, which will do nothing but call some custom methods and eventually startActivity(Intent)
, based upon certain criteria. This activity has nothing to display/render to the user.
What best practices should I follow? Of course, I wish to incur the least rendering time (nothing to display), but I will need to use the Context
for other actions in determining which Activity
to redirect to.
So far I can think of:
android:finishOnTaskLaunch="true开发者_如何学C"
android:stateNotNeeded="true"
- Call
finish()
after callingstartActivity(Intent)
in dispatcher activity
You should consider putting the finish() function in the onPause(...) method. When the other Activity comes in foreground, the onPause(...) of the dispatcher Activity will be called by the system normally and if you call the finish() here, you can be sure that the dispatcher Activity will be finished when another comes in foreground.
精彩评论