androidandroid-studioandroid-intentandroid-virtual-keyboard

How to open an activity from the keyboard list?


I'm developping a custom keyboard, and want to add a preference page.

I noticed that gboard was able to open its preference acivity from the virtual keyboard list in the android settings.

android keyboard list

I tried to do the same, but I can't find any information on how to do this. I tried to search for an intent, but failed to find any.

Do you have an idea ?

Edit : Here is my manifest

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.yvo.mockingkeyboard">
    <uses-permission android:name="android.permission.VIBRATE"/>

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">

        <activity android:name="RootPreferences" android:label="@string/settings_name" android:launchMode="singleTask">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
            </intent-filter>
        </activity>

        <service
            android:name="MockingKeyboard"
            android:label="Mocking Keyboard"
            android:permission="android.permission.BIND_INPUT_METHOD"
            >
            <meta-data android:name="android.view.im" android:resource="@xml/method"/>
            <intent-filter>
                <action android:name="android.view.InputMethod"/>
            </intent-filter>
        </service>

        <provider
            android:name="androidx.core.content.FileProvider"
            android:authorities="com.yvo.mockingkeyboard.fileprovider"
            android:grantUriPermissions="true"
            android:exported="false">
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/filepaths" />
        </provider>
    </application>

</manifest>

Solution

  • I found what was lacking for the settings to show up.
    You need to add the attribute

    android:settingsActivity="com.example.package.PreferencesActivity"
    

    In your method.xml, inside the tag

    <input-method>