InputMethodManager
类中的showSoftInputFromInputMethod
方法在Android P中已经被废弃。根据文档,我们应该在Android P及以上版本中使用InputMethodService.requestShowSelf(int)
方法。现在问题是,我们如何获取
InputMethodService
类的引用。我尝试创建一个新对象并在其上调用requestShowself()
,但它不起作用。InputMethodService inputMethodService = new InputMethodService();
inputMethodService.requestShowSelf(0);
我们如何在API 28及以上版本中使用建议的替代方式?