Setting “task affinity” programmatically
You cannot. taskAffinity is contained by ActivityInfo, which is member of Activity. Source code of Activity public class Activity extends ContextThemeWrapper … … { // set by the thread after the constructor and before // onCreate(Bundle savedInstanceState) is called. @UnsupportedAppUsage /*package*/ ActivityInfo mActivityInfo; } And ActivityInfo has taskAffinity. Source code of ActivityInfo /** * Information …