If you want to hide the activity, you will hide it to everyone, not only who’s not friends with you. There is a way to do that :
First, go to your account’s settings then scroll down, find “Activity Status”.
Then turn off “Display current activity as a status message”.
Done, you hid your activity to everyone.