Added in API level 34

GrammaticalInflectionManager


public class GrammaticalInflectionManager
extends Object

java.lang.Object
   ↳ android.app.GrammaticalInflectionManager


This class allow applications to control granular grammatical inflection settings (such as per-app grammatical gender).

Summary

Public methods

int getApplicationGrammaticalGender()

Returns the current grammatical gender for the calling app.

int getSystemGrammaticalGender()

Allows privileged preloaded applications to get the system grammatical gender when set.

void setRequestedApplicationGrammaticalGender(int grammaticalGender)

Sets the current grammatical gender for the calling app (keyed by package name and user ID retrieved from the calling pid).

Inherited methods

Public methods

getApplicationGrammaticalGender

Added in API level 34
public int getApplicationGrammaticalGender ()

Returns the current grammatical gender for the calling app. A new value can be requested via setRequestedApplicationGrammaticalGender(int) and will be updated with a new configuration change. The method always returns the value received with the last received configuration change.

Returns
int the value of grammatical gender Value is Configuration.GRAMMATICAL_GENDER_NOT_SPECIFIED, Configuration.GRAMMATICAL_GENDER_NEUTRAL, Configuration.GRAMMATICAL_GENDER_FEMININE, or Configuration.GRAMMATICAL_GENDER_MASCULINE

getSystemGrammaticalGender

Added in API level 35
public int getSystemGrammaticalGender ()

Allows privileged preloaded applications to get the system grammatical gender when set.
Requires android.Manifest.permission.READ_SYSTEM_GRAMMATICAL_GENDER

Returns
int The value of system grammatical gender only if the calling app has the permission, otherwise throwing an exception. Value is Configuration.GRAMMATICAL_GENDER_NOT_SPECIFIED, Configuration.GRAMMATICAL_GENDER_NEUTRAL, Configuration.GRAMMATICAL_GENDER_FEMININE, or Configuration.GRAMMATICAL_GENDER_MASCULINE

Throws
SecurityException If the caller does not have the required permission.

setRequestedApplicationGrammaticalGender

Added in API level 34
public void setRequestedApplicationGrammaticalGender (int grammaticalGender)

Sets the current grammatical gender for the calling app (keyed by package name and user ID retrieved from the calling pid).

Note: Changes to app grammatical gender will result in a configuration change (and potentially an Activity re-creation) being applied to the specified application. For more information, see the section on handling configuration changes. The set grammatical gender are persisted across application restarts; they are backed up if the user has enabled Backup & Restore.`

Parameters
grammaticalGender int: the terms of address the user preferred in an application. Value is Configuration.GRAMMATICAL_GENDER_NOT_SPECIFIED, Configuration.GRAMMATICAL_GENDER_NEUTRAL, Configuration.GRAMMATICAL_GENDER_FEMININE, or Configuration.GRAMMATICAL_GENDER_MASCULINE