That does not seem legally practical getting detained for simply having a empty spray can, that’s just an officer assuming you did vandalism with no proof.
While not opposed to the idea, It shouldn’t require the person to be detained. Would make more sense for them to ask about it then just...