Added Application object to share socket between activities

cherrypicked from 5d7f85f2a3786ab969a47fedfe6cd6e834618a6b