下面列出了android.view.inputmethod.InputMethodManager#getInstance ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public static IWindowSession getWindowSession() {
synchronized (WindowManagerGlobal.class) {
if (sWindowSession == null) {
try {
// 获取 IMM 代理对象
InputMethodManager imm = InputMethodManager.getInstance();
// 获取 WMS 代理对象
IWindowManager windowManager = getWindowManagerService();
// Binder 调用 WMS 的 openSession() 方法
sWindowSession = windowManager.openSession(
new IWindowSessionCallback.Stub() {
@Override
public void onAnimatorScaleChanged(float scale) {
ValueAnimator.setDurationScale(scale);
}
},
imm.getClient(), imm.getInputContext());
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
return sWindowSession;
}
}
private void removeViewLocked(int index, boolean immediate) {
ViewRootImpl root = mRoots.get(index);
View view = root.getView();
if (view != null) {
InputMethodManager imm = InputMethodManager.getInstance();
if (imm != null) {
imm.windowDismissed(mViews.get(index).getWindowToken());
}
}
boolean deferred = root.die(immediate);
if (view != null) {
view.assignParent(null);
if (deferred) {
mDyingViews.add(view);
}
}
}
public Object createService(ContextImpl ctx) {
return InputMethodManager.getInstance(ctx);
}
public Object createService(ContextImpl ctx) {
return InputMethodManager.getInstance(ctx);
}
public Object createStaticService() {
return InputMethodManager.getInstance();
}
public Object createStaticService() {
return InputMethodManager.getInstance();
}
public Object createService(ContextImpl ctx) {
return InputMethodManager.getInstance(ctx);
}
public Object createStaticService() {
return InputMethodManager.getInstance();
}
public Object createStaticService() {
return InputMethodManager.getInstance();
}
@Override
public InputMethodManager createService() {
return InputMethodManager.getInstance();
}