Back to project page ExpertAndroid.
The source code is released under:
MIT License
If you think the Android project ExpertAndroid listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.iuriio.demos.expertandroid.ch9openglexperiments; /* w w w .j ava 2 s . c om*/ import android.app.ActivityManager; import android.content.Context; import android.content.Intent; import android.content.pm.ConfigurationInfo; import android.support.v7.app.ActionBarActivity; import android.support.v7.app.ActionBar; import android.support.v4.app.Fragment; import android.os.Bundle; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.os.Build; public class MainActivity extends ActionBarActivity implements View.OnClickListener { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.setContentView(R.layout.activity_main); this.findViewById(R.id.openglEs10Button).setOnClickListener(this); final View openGl20Button = this.findViewById(R.id.openglEs20Button); if (openGl20Button != null) { if (!this.detectOpenGL20()) { openGl20Button.setEnabled(false); } openGl20Button.setOnClickListener(this); } } private boolean detectOpenGL20() { ActivityManager manager = (ActivityManager) this.getSystemService(Context.ACTIVITY_SERVICE); ConfigurationInfo info = manager.getDeviceConfigurationInfo(); assert info != null; return info.reqGlEsVersion >= 0x20000; } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. switch (item.getItemId()) { case R.id.action_settings: return true; } return super.onOptionsItemSelected(item); } /** * Called when a view has been clicked. * * @param v The view that was clicked. */ @Override public void onClick(View v) { switch (v.getId()) { case R.id.openglEs10Button: this.startActivity(new Intent(this, OpenGLES10Activity.class)); break; case R.id.openglEs20Button: this.startActivity(new Intent(this, OpenGLES20Activity.class)); break; } } }