Put this code in your AndroidManifest.xml
file in your activity tag-
<activity
android:name="com.example.YourActivity"
android:configChanges="keyboard|keyboardHidden|
orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:windowSoftInputMode="stateHidden|adjustPan">
</activity>