【问题标题】:Android - Determine Calling Application of an InputMethod (Custom Keyboard)Android - 确定输入法的调用应用程序(自定义键盘)
【发布时间】:2016-02-19 01:28:49
【问题描述】:

我正在按照本指南实施自定义键盘:http://developer.android.com/guide/topics/text/creating-input-method.html

有没有办法从我的 KeyboardService 中“连接”到哪个应用程序(=包 id)(哪个应用程序接收我发送的输入事件)?

【问题讨论】:

    标签: android keyboard android-service android-input-method android-service-binding


    【解决方案1】:

    奇怪,一天看6次,觉得这个话题比较有趣。好吧,无论如何,我找到了一个解决方案,如果有人需要,这里是代码。

    InputMethodService 可以收到InputBinding

    private String getCallerPackageId() {
        InputBinding binding = getCurrentInputBinding();
        return getApplicationContext().getPackageManager().getNameForUid(binding.getUid());
    }
    

    【讨论】:

    • getCurrentInputBinding() 是什么?
    • 什么是getCurrentInputBinding()?请给我那个方法。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-07-19
    • 1970-01-01
    • 2014-06-25
    • 2014-04-18
    • 2012-06-13
    • 2011-03-12
    相关资源
    最近更新 更多