开发者

activity to dispatch or redirect to other activities

开发者 https://www.devze.com 2023-03-31 18:29 出处:网络
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. T

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:

  1. android:finishOnTaskLaunch="true开发者_如何学C"
  2. android:stateNotNeeded="true"
  3. Call finish() after calling startActivity(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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号