Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7887721
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:39:16+00:00 2026-06-03T05:39:16+00:00

I want to get user input for my OpenGL ES 2.0 application, but there

  • 0

I want to get user input for my OpenGL ES 2.0 application, but there are 2 problems:

  • 1) How can I bring the software keyboard to the front of my app?
  • 2) How can I catch input from it?

I tried to use this:

//OpenGL ES 2.0 view class
public class OGLES2View extends GLSurfaceView 
{
    private static final int OGLES_VERSION = 2;
    private static Handler softKeyboardHandler;
    private final static int SHOW_IME_KEYBOARD = 0;
    private final static int HIDE_IME_KEYBOARD = 1;
    private static EditText textEdit;
    private static  InputMethodManager imm;

    private void setSoftKeyboardHandler()
    {
        softKeyboardHandler = new Handler()
        {
            public void handleMessage(Message msg)
            {
                switch(msg.what)
                {
                    case SHOW_IME_KEYBOARD:
                        textEdit.requestFocus();
                        imm.showSoftInput(textEdit,inputMethodManager.SHOW_IMPLICIT);//Nothing happens
                        Log.i("GLVIEW","SHOW KEYBOARD");
                        break;

                    case HIDE_IME_KEYBOARD:
                        imm.hideSoftInput(textEdit, 0);
                        Log.i("GLVIEW","HIDE KEYBOARD");
                        break;

                    default:
                        break;
                }
            }
        };
    }

    public OGLES2View(Context context) 
    {
        super(context);
        textEdit = new EditText(context);
        setEGLContextClientVersion(OGLES_VERSION);
        setRenderer(new OGLES2Renderer());
        imm = (InputMethodManager)context.getSystemService(Context.INPUT_METHOD_SERVICE);
        setSoftKeyboardHandler();
    }

    public static void showIMEKeyboard() 
    {
        softKeyboardHandler.sendEmptyMessage(SHOW_IME_KEYBOARD);
    }

    public static void hideIMEKeyboard()
    {
        softKeyboardHandler.sendEmptyMessage(HIDE_IME_KEYBOARD);
    }

    //In main activity class
    private GLSurfaceView ogles2SurfaceView = null;

    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        //...
        ogles2SurfaceView = new OGLES2View(this);
        setContentView(ogles2SurfaceView);
    }

Handler gets messages, but I got no software keyboard.
To catch text, I wrote some class:

public class TextInputWatcher implements TextWatcher

and:

textEdit.addTextChangedListener(/*TextInputWatcher instance*/);

Or extend a TextEdit so it catches inputed text on back or enter key.

P.S. I got a tablet – transformer, so there is a hardware keyboard attached. I tried with it and without, but no difference. So bonus question – if there is a hardware keyboard will it prevent a software keyboard from popping up and how can input be gotten from it then?.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T05:39:18+00:00Added an answer on June 3, 2026 at 5:39 am

    Show keyboard:

    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
    

    Hide keyboard:

    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to simply get the user to input a number. I can get
i have a simple macruby application and i want to get some user-input via
Hi In my android app, I want to get user's input from a EditText
i want to get the full address of user programatically using c# how can
For example, in the main function, I want to get the user's input. Depending
I want to get user input using a pop-up dialog box. I am able
i want to get matrix values, rows and coloumn from user input. So i'm
Writing a bash script, and I want to get user input. Awesome, read -p
I want to get the user input for the EditText view and display it
If I want to get a user input from Console to my Expression Tree.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.