malhobayyeb
malhobayyeb

Reputation: 2883

How to find out what action and/or flag is used with imeOptions?

In the following code:

public InputConnection onCreateInputConnection(EditorInfo outAttrs) {

    InputConnection  inputConnection  = super.onCreateInputConnection(outAttrs);

    // What is included in the outAttrs.imeOptions

    return inputConnection  ;
}

outAttrs.imeOptions is an integer value representing EditorInfo actions and flags.

How to detect which action/flag is used within outAttrs.imeOptions?

I tried to read the number but I found out it is a long number something like: 301216460

I found that setting this value is done using & and |:

outAttrs.imeOptions |= EditorInfo.IME_ACTION_NEXT;

Upvotes: 0

Views: 332

Answers (2)

user6490462
user6490462

Reputation:

I think it's not a good idea to use bitwise operator here my brother, instead of that you can check on your input variable whatever is it, e.g:

if (editText.getImeOptions() == EditorInfo.IME_ACTION_NEXT)
    //do it
else
    //not this time.

Upvotes: 1

malhobayyeb
malhobayyeb

Reputation: 2883

I found how to determine if an action or a flag is included in the imeOptions value.

To check if EditorInfo.IME_ACTION_NEXT is included in the imeOptions value:

if ((imeOptions & EditorInfo.IME_ACTION_NEXT) == EditorInfo.IME_ACTION_NEXT) {
// imeOptions includes EditorInfo.IME_ACTION_NEXT
} else {
// imeOptions does not include EditorInfo.IME_ACTION_NEXT
}

Upvotes: 0

Related Questions