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 4059178
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T15:10:29+00:00 2026-05-20T15:10:29+00:00

I have followed the onTouch example from google located here . However, I get

  • 0

I have followed the onTouch example from google located here. However, I get nothing out in my logs. As far as I can tell, my view is not picking up any of the on touch events. This is my code:

package com.test;

import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;

import android.app.Activity;
import android.content.Context;
import android.opengl.GLSurfaceView;
import android.os.Bundle;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.Window;

public class intro extends Activity {
    static{
        System.loadLibrary("graphrender");
    }
    private GLSurfaceView mGLView;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        mGLView = new GraphGLSurfaceView(this);
        setContentView(mGLView);

    }

    @Override
    protected void onPause() {
        super.onPause();
        mGLView.onPause();
    }

    @Override
    protected void onResume() {
        super.onResume();
        mGLView.onResume();
    }
}

class GraphGLSurfaceView extends GLSurfaceView {
    GraphRenderer mRenderer;    
    public GraphGLSurfaceView(Context context) {
        super(context);
        mRenderer = new GraphRenderer();
        setRenderer(mRenderer);

    }
    public boolean onTouch(View v, MotionEvent event)
    {
        queueEvent(new Runnable(){
            public void run() {
                mRenderer.shout();
            }});
            return true;
    }
}

class GraphRenderer implements GLSurfaceView.Renderer { 
    private static native void nativeSetup();
    private static native void nativeSize(int w, int h);
    private static native void nativeRender();


    private float _red = 0.9f;
    private float _green = 0.2f;
    private float _blue = 0.2f;

    public void onSurfaceCreated(GL10 gl, EGLConfig config) {
        nativeSetup();
        Log.d("intro", "Got to intro 4" );
    }

    public void onSurfaceChanged(GL10 gl, int w, int h) {
        nativeSize(w,h);
    }

    public void onDrawFrame(GL10 gl) {
        nativeRender();
    }
    public void shout()
    {
        Log.d("Graph Page", "gotta graph");
    }
}

The only thing I can think of is that I have to have something fancy in the xml file or set its focus. Any help would be appreciated.

  • 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-05-20T15:10:30+00:00Added an answer on May 20, 2026 at 3:10 pm

    Well that is because if you look at the API for GLSurfaceView it does not actually have a onTouch method for you to override. That means that the onTouch method will never be called which probably explains why you never see it being run. Instead, if you want to get the touch events then you should override onTouchEvent in the Activity instead. Like this:

    public class Intro extends Activity {
        static{
            System.loadLibrary("graphrender");
        }
        private GLSurfaceView mGLView;
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            requestWindowFeature(Window.FEATURE_NO_TITLE);
            mGLView = new GraphGLSurfaceView(this);
            setContentView(mGLView);
    
        }
    
        @Override
        protected boolean onTouchEvent(MotionEvent event) {
            Log.i("motion", event);
            return true;
        }
    
        @Override
        protected void onPause() {
            super.onPause();
            mGLView.onPause();
        }
    
        @Override
        protected void onResume() {
            super.onResume();
            mGLView.onResume();
        }
    }
    

    And that should now work.

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

Sidebar

Related Questions

I have followed the Hello World example from Google's Android developer's guide. When I
I have followed the suggestions from this post to try and get Distinct() working
I have followed all the instructions here: http://www.tonyspencer.com/2003/10/22/curl-with-php-and-apache-on-windows/ to install & config apache get
Here's the situation: I have a label's text set, immediately followed by a response.redirect()
Have followed every step correctly from this link http://msdn.microsoft.com/en-us/library/ms746621.aspx When trying to localize the
I have followed all the rules of memory management but can someone explain to
I have followed the instructions on this page to get started on ActionMailer. After
I have followed the instructions here . To cut a long story short, I
I have followed the blog post written by Steve Sanderson at blog.codeville.net/2008/10/14/partial-requests-in-aspnet-mvc . It
I have followed the suggestion in this question... [ How to handle checkboxes in

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.