【问题标题】:Android Manifest for Keyboard not Showing in Settings键盘的 Android 清单未显示在设置中
【发布时间】:2012-09-02 19:34:07
【问题描述】:

我正在制作我的第一个 Android 应用程序,我需要它作为键盘服务。据我所知,清单看起来不错,而且我有一个文件 WifiJoy.java(在 com.zwad3.wifijoy 包中)以及所有其他文件。

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.zwad3.wifijoy"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="9"
        android:targetSdkVersion="15" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"></uses-permission>
    <uses-permission android:name="android.permission.INTERNET"></uses-permission>
    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <service android:name="com.zwad3.wifijoy.WifiJoy"
            android:label="Wifi Joystick"
            android:permission="android.permission.BIND_INPUT_METHOD">
            <intent-filter>
                <action android:name="android.view.InputMethod" />
            </intent-filter>
        </service>

        <activity
            android:name=".settings"
            android:label="@string/title_activity_settings" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

这里是WifiJoy.java的开始

package com.zwad3.wifijoy;

import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
import android.inputmethodservice.InputMethodService;

public class WifiJoy extends InputMethodService {

我知道这是不完整的,所以如果您需要更多信息,请告诉我,我只是不想让帖子超载。

【问题讨论】:

    标签: android xml keyboard


    【解决方案1】:

    尝试在您的 &lt;service&gt; 中添加一个 &lt;meta-data&gt; 元素,例如 SoftKeyboard SDK 示例的此清单中显示的元素:

    <manifest xmlns:android="http://schemas.android.com/apk/res/android" 
            package="com.example.android.softkeyboard">
        <application android:label="@string/ime_name">
            <service android:name="SoftKeyboard"
                    android:permission="android.permission.BIND_INPUT_METHOD">
                <intent-filter>
                    <action android:name="android.view.InputMethod" />
                </intent-filter>
                <meta-data android:name="android.view.im" android:resource="@xml/method" />
            </service>
    
            <activity android:name=".ImePreferences" android:label="@string/settings_name">
                <intent-filter>
                    <action android:name="android.intent.action.MAIN"/>
                </intent-filter>
            </activity>
    
        </application>
    </manifest>
    

    这将指向res/xml/ 中的一个 XML 文件(在上面的示例中名为 method.xml),其中包含有关您的 IME 的描述性信息,例如来自同一 SDK 示例的此文件:

    <input-method xmlns:android="http://schemas.android.com/apk/res/android"
            android:settingsActivity="com.example.android.softkeyboard.ImePreferences"
    >
        <subtype
            android:label="@string/label_subtype_generic"
            android:icon="@drawable/icon_en_us"
            android:imeSubtypeLocale="en_US"
            android:imeSubtypeMode="keyboard" />
        <subtype
            android:label="@string/label_subtype_en_GB"
            android:icon="@drawable/icon_en_gb"
            android:imeSubtypeLocale="en_GB"
            android:imeSubtypeMode="keyboard" />
    </input-method>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-09-23
      • 2020-05-04
      • 1970-01-01
      • 2016-12-31
      • 1970-01-01
      • 2015-09-08
      相关资源
      最近更新 更多