fix android background and foreground crash for primitive