Finally after struggling with this problem, I found a possible solution. Maybe it is not the best but I had no other and it workd.
I used shared preferences to store the info. I created a launcher activity with the implemented GLSurfaceView with a delay of 3 seconds (more than enough to store all the strings) and after this delay the activity I need starts.
The launcher activity looks like this:
package system.info.to.txt;
import java.util.Random;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.opengl.GLSurfaceView;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.util.Log;
public class RendererLoader extends Activity {
private static SharedPreferences prefs;
private static SharedPreferences.Editor editor;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
prefs = this.getSharedPreferences("GPUinfo", Context.MODE_PRIVATE);
mGLView = new GLSurfaceView(this);
mGLView.setRenderer(new ClearRenderer());
setContentView(mGLView);
final Intent intent = new Intent(this, Info.class);
new CountDownTimer(3000, 9999)
{
public void onTick(long millisUntilFinished) {
// Not used
}
public void onFinish() {
startActivity(intent);
finish();
}
}.start();
}
private GLSurfaceView mGLView;
class ClearRenderer implements GLSurfaceView.Renderer {
Random aleatorio = new Random();
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
float r = aleatorio.nextFloat();
float g = aleatorio.nextFloat();
float b = aleatorio.nextFloat();
gl.glClearColor(r, g, b, 1.0f);
editor = prefs.edit();
editor.putString("RENDERER", gl.glGetString(GL10.GL_RENDERER));
editor.putString("VENDOR", gl.glGetString(GL10.GL_VENDOR));
editor.putString("VERSION", gl.glGetString(GL10.GL_VERSION));
editor.putString("EXTENSIONS", gl.glGetString(GL10.GL_EXTENSIONS));
editor.commit();
}
public void onSurfaceChanged(GL10 gl, int w, int h) {
}
public void onDrawFrame(GL10 gl) {
gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
}
}
}
After that, you can retrieve the stored strings everywhere you want in your application using:
SharedPreferences prefs =getSharedPreferences("GPUinfo",Context.MODE_PRIVATE);
String vendor = prefs.getString("VENDOR", null);
String renderer = prefs.getString("RENDERER", null);
String version = prefs.getString("VERSION", null);
String extensions = prefs.getString("EXTENSIONS", null);
I hope this answer will be useful for the people with the same problem. Any other solution will be also helpful.