-
Notifications
You must be signed in to change notification settings - Fork 1
/
AndroidUtilities.java
61 lines (49 loc) · 1.62 KB
/
AndroidUtilities.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package com.example.jeffreynyauke.myapplication.utils;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import java.io.File;
/**
* Created by Jeffrey Nyauke on 2/3/2017.
*/
public class AndroidUtilities {
public static void showKeyboard(View view) {
if (view == null) {
return;
}
try {
InputMethodManager inputManager = (InputMethodManager)view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
inputManager.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
} catch (Exception e) {
//FileLog.e("tmessages", e);
}
}
public static boolean isKeyboardShowed(View view) {
if (view == null) {
return false;
}
try {
InputMethodManager inputManager = (InputMethodManager) view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
return inputManager.isActive(view);
} catch (Exception e) {
//FileLog.e("tmessages", e);
}
return false;
}
public static void hideKeyboard(View view) {
if (view == null) {
return;
}
try {
InputMethodManager imm = (InputMethodManager) view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
if (!imm.isActive()) {
return;
}
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
} catch (Exception e) {
//FileLog.e("tmessages", e);
}
}
}