Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/219.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在android中,为什么GetCurrentInputItemInfo()=null?_Android - Fatal编程技术网

在android中,为什么GetCurrentInputItemInfo()=null?

在android中,为什么GetCurrentInputItemInfo()=null?,android,Android,单击流窗口按钮时,应用程序启动服务扩展InputMethodService,如下所示: public void onStart(Intent intent, int a) { super.onStart(intent , a); EditorInfo ed=getCurrentInputEditorInfo(); } 问题是,无论当前活动(来自其他应用程序)是什么,“ed”都等于“null”,当然下面的代码,例如“Log.d(“tag”,ed.hintText+”)”会出错。 语法不正确,或者

单击流窗口按钮时,应用程序启动服务扩展
InputMethodService
,如下所示:

public void onStart(Intent intent, int a)
{
super.onStart(intent , a);
EditorInfo ed=getCurrentInputEditorInfo();
}
问题是,无论当前活动(来自其他应用程序)是什么,“ed”都等于“null”,当然下面的代码,例如
“Log.d(“tag”,ed.hintText+”)”
会出错。
语法不正确,或者应用程序缺少某些权限?

因为只有连接到文本编辑器后,EditorInfo才会存在。这不会发生在onStart中,而是发生在onStartInput中。其中它也作为参数传递,这使得这个函数有点不必要。

但我不重写InputMethod。我只希望当当前活动中有编辑器时,我可以自动向其填充一些消息。因此,我的首要任务是找到编辑信息。我怎么能做到呢?如果你没有编写InputMethod,那么你就不需要知道编辑器信息。我想你是糊涂了。你到底想做什么?我正在写一个应用程序,它可以自动填写验证表单。例如,当应用程序在后台运行时,当我启动Youtube时,它可以检测editorInfo并用从数据库获取的数据填充id和密码。editorInfo只是一个输入法的概念。它提供了关于当前附加到输入法的编辑器的通用类型的非常有限的信息,用户在其中点击以聚焦。您想要做的是成为浏览器的一部分,一个插件。即使您能够获得EditorInfo,它通常也不会为您提供比数字/文本/密码更多的信息,可能还会为caps模式提供一些标志。它永远不会说“Yahoo登录id”或“Yahoo密码”。而且,只有当前选择的输入法会被用户选择的键盘调用。它不像Android用这些信息调用每一个输入法服务。因此,除非您是当前的键盘,否则您不会被呼叫并传递编辑器信息。