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

  • SEARCH
  • Home
  • 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 7884735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:52:52+00:00 2026-06-03T04:52:52+00:00

I wrote a cellphone interface for a measurement device. I have a bunch of

  • 0

I wrote a cellphone interface for a measurement device. I have a bunch of distinct functional screens in the from of GLSurfaceViews. I can launch the renders correctly, but I can’t figure out how to make the back button work.
My render code looks like:

Button mSpecButton = new Button(this);
mSpecButton.setText("Spectrometer");
mSpecButton.setOnClickListener(new View.OnClickListener()
{
    public void onClick(View v)
    {
        glSurfaceView = new GLSurfaceView(mRun);
        mRender = new renderSpectro(mRun);
        glSurfaceView.setRenderer(mRender);
        setContentView(glSurfaceView);
    }
});

I can’t figure out where to put a public boolean onKeyDown(int keyCode, KeyEvent event)

  • 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-03T04:52:54+00:00Added an answer on June 3, 2026 at 4:52 am

    The onKeyDown() method must be placed in the activity. if you want to use it to control the GLSurfaceView or Renderer you must use some other way to send it there. For example in your main activity you can have:

    //Somewhere in the code
    GLSurfaceView glSurfaceView = new myGLSurfaceView();
    
    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        glSurfaceView.doBackAction(); //Or something similar
    }
    

    And in your myGLSurfaceView you just have a method:

    public void doBackAction() {
        //Yay
    }
    

    If you are concerned about thread safety it gets a little more complicated but the initial onKeyDown() must be in the activity.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote a routine to remove pounds and ids from sharepoint fields that worked
I wrote an application using ASP.NET MVC, in this application I have an Index
I wrote a makefile which behaves oddly. You can find it here: http://pastebit.com/pastie/8215 Basically
I have this cellphone which runs Android OS 2.6. Due to some reasons, I
I wrote a webpage where a user can enter a log entry that is
I wrote this ruby script to scrape product info from the manufacturer website. The
I wrote this code to scrape a sparse array from a series of dom
I wrote a simple script trying to programmatically create a script from the onEdit
I wrote a batch to check and deploy the rails app from github, the
I wrote a bunch of jQuery files to manipulate my software. My software is

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.