fix android background and foreground crash for primitive
Merge pull request #7793 from dabingnn/v3_fixRandomCrashForPrimitive

fix android background and foreground crash for primitive