Android 4.1: How to "implement custom installation layouts"?

Description:

“User-defined keyboard layouts” is a feature specified for Android 4.1 at http://developer.android.com/about/versions/jelly-bean.html .

It says:

The platform now supports user-defined keyboard maps, such as additional international keyboards and special layout types. By default, Android 4.1 includes 27 international keyboard layouts, including Dvorak. When users connect the keyboard, they can go to the Settings app and select one or more layouts that they want to use for this keyboard. When typing, users can switch between key cards using the shortcut (ctrl-space). You can create an application for publishing additional layouts in the system. The APK will include keyboard layout resources based on the standard Android keyboard format. An application can offer additional keyboard layouts to a user by declaring a suitable broadcast receiver for ACTION_QUERY_KEYBOARD_LAYOUTS in their manifest.

So, I want to encode an application that adds a new keyboard layout. So, I have to create a new BroadcastReveiver and declare it for ACTION_QUERY_KEYBOARD_LAYOUTS in the application manifest. The application also provides a file card.

So my question is: What should BroadcastReceiver do when it receives the ACTION_QUERY_KEYBOARD_LAYOUTS intent?

I did quite a few searches - however, only the sites containing ACTION_QUERY_KEYBOARD_LAYOUTS , I could find where those that copied the description above from developer.android.com.

I would really appreciate any help,

Yours faithfully,
Randall

+4
source share
1 answer

You need to create one or more suitable files with key symbols as raw resource files, named for example. mykeyboard.kcm in your project.

Add the appropriate receiver to the manifest (AndroidManifest.xml) using KEYBOARD_LAYOUTS, pointing to an XML resource that lists all .kcm files as a keyboard layout. You do not enter any real Java or native code, just manifest and resource files.

https://github.com/tialaramex/BritishKeyboard

The link above is an example that I had to build before, which (basically) makes the layout in English (United Kingdom) available instead of the usual default US keyboard, for example. pressing SHIFT and 2 gives you a double quote instead of the @ character. Hope this is simple enough if you know a little about Android projects.

The end result is that when you connect a USB or Bluetooth keyboard, the prompt for setting the keyboard layout lists any additional keyboard layouts installed by applications, in which case one of them is marked as English (UK).

+4
source

Source: https://habr.com/ru/post/1445396/


All Articles