Created
September 17, 2018 10:34
-
-
Save abhinav272/d0456405623761aff3f40d8260fd607f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.annotation.SuppressLint; | |
import android.app.Activity; | |
import android.content.Context; | |
import android.provider.Settings; | |
import android.view.inputmethod.InputMethodManager; | |
public class AppUtils { | |
public static void hideKeyboard(Activity context) { | |
try { | |
InputMethodManager inputManager = (InputMethodManager) context.getApplicationContext().getSystemService(Context.INPUT_METHOD_SERVICE); | |
inputManager.hideSoftInputFromWindow(context.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} | |
} | |
public static void showKeyboard(Activity context) { | |
try { | |
InputMethodManager inputMethodManager = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); | |
inputMethodManager.showSoftInput(context.getCurrentFocus(), InputMethodManager.SHOW_IMPLICIT); | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} | |
} | |
@SuppressLint("HardwareIds") | |
public static String getUniqueDeviceId(Context context) { | |
return Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment