Java Code Examples for android.app.ActivityManager#getDeviceConfigurationInfo()

The following examples show how to use android.app.ActivityManager#getDeviceConfigurationInfo() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GlUtil.java    From sealrtc-android with MIT License 6 votes vote down vote up
/**
 * Prefer OpenGL ES 3.0, otherwise 2.0
 *
 * @param context
 * @return
 */
public static int getSupportGLVersion(Context context) {
    final ActivityManager activityManager =
            (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
    int version = configurationInfo.reqGlEsVersion >= 0x30000 ? 3 : 2;
    String glEsVersion = configurationInfo.getGlEsVersion();
    Log.d(
            TAG,
            "reqGlEsVersion: "
                    + Integer.toHexString(configurationInfo.reqGlEsVersion)
                    + ", glEsVersion: "
                    + glEsVersion
                    + ", return: "
                    + version);
    return version;
}
 
Example 2
Source File: MainActivity.java    From opengl with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	// Turn off the window's title bar
	requestWindowFeature(Window.FEATURE_NO_TITLE);

	super.onCreate(savedInstanceState);
	mGLSurfaceView = new GLSurfaceView(this);
	// Check if the system supports OpenGL ES 2.0.
	final ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
	final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
	final boolean supportsEs2 = configurationInfo.reqGlEsVersion >= 0x20000;
	if (supportsEs2)
	{
		// Request an OpenGL ES 2.0 compatible context.
		mGLSurfaceView.setEGLContextClientVersion(2);
		// Set the renderer to our demo renderer, defined below.
		mGLSurfaceView.setRenderer(new LessonOneRenderer());
	}
	else
	{
		// This is where you could create an OpenGL ES 1.x compatible
		// renderer if you wanted to support both ES 1 and ES 2.
		return;
	}
	setContentView(mGLSurfaceView);
}
 
Example 3
Source File: GLSurfaceView.java    From NewsMe with Apache License 2.0 6 votes vote down vote up
private void checkGLESVersion() {
	if (!mGLESVersionCheckComplete) {
		// mGLESVersion = SystemProperties.getInt(
		// "ro.opengles.version",
		// ConfigurationInfo.GL_ES_VERSION_UNDEFINED);
		ActivityManager am = (ActivityManager) context
				.getSystemService(Context.ACTIVITY_SERVICE);
		ConfigurationInfo info = am.getDeviceConfigurationInfo();
		mGLESVersion = info.reqGlEsVersion;
		if (mGLESVersion >= kGLES_20) {
			mMultipleGLESContextsAllowed = true;
		}
		if (LOG_SURFACE) {
			Log.w(TAG, "checkGLESVersion mGLESVersion =" + " "
					+ mGLESVersion + " mMultipleGLESContextsAllowed = "
					+ mMultipleGLESContextsAllowed);
		}
		mGLESVersionCheckComplete = true;
	}
}
 
Example 4
Source File: DemoActivity.java    From StarWars.Android with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_demo);
    ButterKnife.bind(this);

    // Check if the system supports OpenGL ES 2.0.
    final ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
    final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
    final boolean supportsEs2 = configurationInfo.reqGlEsVersion >= 0x20000;

    if (supportsEs2) {
        // Request an OpenGL ES 2.0 compatible context.
        mGlSurfaceView.setEGLContextClientVersion(2);

        // Set the renderer to our demo renderer, defined below.
        ParticleSystemRenderer mRenderer = new ParticleSystemRenderer(mGlSurfaceView);
        mGlSurfaceView.setRenderer(mRenderer);
        mGlSurfaceView.setRenderMode(GLSurfaceView.RENDERMODE_CONTINUOUSLY);
    } else {
        throw new UnsupportedOperationException();
    }

    if (savedInstanceState == null) {
        showGreetings();
    }

}
 
Example 5
Source File: ARView.java    From geoar-app with Apache License 2.0 5 votes vote down vote up
private void init() {
	if (isInEditMode()) {
		return;
	}

	mCameraView = new CameraView(getContext());
	addView(mCameraView, LayoutParams.MATCH_PARENT,
			LayoutParams.MATCH_PARENT);

	final ActivityManager activityManager = (ActivityManager) getContext()
			.getSystemService(Context.ACTIVITY_SERVICE);
	final ConfigurationInfo config = activityManager
			.getDeviceConfigurationInfo();

	if (config.reqGlEsVersion >= 0x20000 || Build.PRODUCT.startsWith("sdk")) {
		// Add ARSurfaceView only if OpenGL ES Version 2 supported
		mARSurfaceView = new ARSurfaceView(this);
		mARSurfaceView.setKeepScreenOn(true);
		mARSurfaceView.setZOrderMediaOverlay(true);
		addView(mARSurfaceView, new FrameLayout.LayoutParams(
				LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
	}

	mCanvasOverlayView = new ARCanvasSurfaceView(this);
	addView(mCanvasOverlayView, LayoutParams.MATCH_PARENT,
			LayoutParams.MATCH_PARENT);
}
 
Example 6
Source File: GlUtil.java    From PLDroidShortVideo with Apache License 2.0 5 votes vote down vote up
public static int getSupportGLVersion(Context context) {
    final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
    int version = configurationInfo.reqGlEsVersion >= 0x30000 ? 3 : 2;
    String glEsVersion = configurationInfo.getGlEsVersion();
    Log.e(TAG, "reqGlEsVersion: " + Integer.toHexString(configurationInfo.reqGlEsVersion) + ", glEsVersion:" + glEsVersion);
    return version;
}
 
Example 7
Source File: ViEAndroidGLES20.java    From CSipSimple with GNU General Public License v3.0 5 votes vote down vote up
public static boolean IsSupported(Context context) {
    ActivityManager am =
            (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    ConfigurationInfo info = am.getDeviceConfigurationInfo();
    if(info.reqGlEsVersion >= 0x20000) {
        // Open GL ES 2.0 is supported.
        return true;
    }
    return false;
}
 
Example 8
Source File: AndEngine.java    From tilt-game-android with MIT License 5 votes vote down vote up
private static void checkGLES20Support(final Context pContext) throws DeviceNotSupportedException {
	final ActivityManager activityManager = (ActivityManager) pContext.getSystemService(Context.ACTIVITY_SERVICE);

	final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();

	if (configurationInfo.reqGlEsVersion < 0x20000) {
		throw new DeviceNotSupportedException(DeviceNotSupportedCause.GLES2_UNSUPPORTED);
	}
}
 
Example 9
Source File: MainActivity.java    From opengl with Apache License 2.0 5 votes vote down vote up
private boolean detectOpenGLES30()
{
    ActivityManager am =
            ( ActivityManager ) getSystemService ( Context.ACTIVITY_SERVICE );
    ConfigurationInfo info = am.getDeviceConfigurationInfo();
    return ( info.reqGlEsVersion >= 0x30000 );
}
 
Example 10
Source File: GLWallpaperService.java    From alynx-live-wallpaper with Apache License 2.0 5 votes vote down vote up
private void createGLSurfaceView() {
    if (glSurfaceView != null) {
        glSurfaceView.onDestroy();
        glSurfaceView = null;
    }
    glSurfaceView = new GLWallpaperSurfaceView(context);
    final ActivityManager activityManager = (ActivityManager)getSystemService(
        Context.ACTIVITY_SERVICE
    );
    if (activityManager == null) {
        throw new RuntimeException("Cannot get ActivityManager");
    }
    final ConfigurationInfo configInfo = activityManager.getDeviceConfigurationInfo();
    if (configInfo.reqGlEsVersion >= 0x30000) {
        Utils.debug(TAG, "Support GLESv3");
        glSurfaceView.setEGLContextClientVersion(3);
        renderer = new GLES30WallpaperRenderer(context);
    } else if (configInfo.reqGlEsVersion >= 0x20000) {
        Utils.debug(TAG, "Fallback to GLESv2");
        glSurfaceView.setEGLContextClientVersion(2);
        renderer = new GLES20WallpaperRenderer(context);
    } else {
        Toast.makeText(context, R.string.gles_version, Toast.LENGTH_LONG).show();
        throw new RuntimeException("Needs GLESv2 or higher");
    }
    glSurfaceView.setPreserveEGLContextOnPause(true);
    glSurfaceView.setRenderer(renderer);
    // On demand render will lead to black screen.
    glSurfaceView.setRenderMode(GLSurfaceView.RENDERMODE_CONTINUOUSLY);
}
 
Example 11
Source File: VideoView.java    From NewsMe with Apache License 2.0 5 votes vote down vote up
public static boolean IsSupported(Context context) {
	LogS.d(TAG, " IsSupported()");

	ActivityManager am = (ActivityManager) context
			.getSystemService(Context.ACTIVITY_SERVICE);
	ConfigurationInfo info = am.getDeviceConfigurationInfo();
	if (info.reqGlEsVersion >= 0x20000) {
		// Open GL ES 2.0 is supported.
		return true;
	}
	return false;
}
 
Example 12
Source File: Utils.java    From LearnOpenGL with MIT License 4 votes vote down vote up
public static boolean supportGlEs20(Activity activity) {
    ActivityManager activityManager = (ActivityManager) activity.getSystemService(
            Context.ACTIVITY_SERVICE);
    return activityManager.getDeviceConfigurationInfo().reqGlEsVersion >= 0x20000;
}
 
Example 13
Source File: GLUtil.java    From CameraCompat with MIT License 4 votes vote down vote up
public static boolean isSupportOpenGLES2(final Context context) {
    final ActivityManager activityManager =
            (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
    return configurationInfo.reqGlEsVersion >= 0x20000;
}
 
Example 14
Source File: MainActivity.java    From opengl with Apache License 2.0 4 votes vote down vote up
private boolean detectOpenGLES30() {
    ActivityManager am =
            (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
    ConfigurationInfo info = am.getDeviceConfigurationInfo();
    return (info.reqGlEsVersion >= 0x30000);
}
 
Example 15
Source File: GLUtils.java    From Spectaculum with Apache License 2.0 4 votes vote down vote up
/**
 * Checks if the system supports OpenGL ES 2.0.
 */
public static boolean isGlEs2Supported(Context context) {
    ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
    return configurationInfo != null && configurationInfo.reqGlEsVersion >= 0x20000;
}
 
Example 16
Source File: MainActivity.java    From opengl with Apache License 2.0 4 votes vote down vote up
private boolean detectOpenGLES30() {
    ActivityManager am =
        (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
    ConfigurationInfo info = am.getDeviceConfigurationInfo();
    return (info.reqGlEsVersion >= 0x30000);
}
 
Example 17
Source File: MainActivity.java    From opengl with Apache License 2.0 4 votes vote down vote up
private boolean detectOpenGLES30() {
    ActivityManager am =
            (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
    ConfigurationInfo info = am.getDeviceConfigurationInfo();
    return (info.reqGlEsVersion >= 0x30000);
}
 
Example 18
Source File: MainActivity.java    From GLEXP-Team-onebillion with Apache License 2.0 4 votes vote down vote up
public void doGLStuff ()
{
    glSurfaceView = new OBGLView(this);
    glSurfaceView.setPreserveEGLContextOnPause(true);
    // Check if the system supports OpenGL ES 2.0.
    final ActivityManager activityManager =
            (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);

    final ConfigurationInfo configurationInfo =
            activityManager.getDeviceConfigurationInfo();
    /*

    final boolean supportsEs2 = configurationInfo.reqGlEsVersion >= 0x20000;
     */
    // Even though the latest emulator supports OpenGL ES 2.0,
    // it has a bug where it doesn't set the reqGlEsVersion so
    // the above check doesn't work. The below will detect if the
    // app is running on an emulator, and assume that it supports
    // OpenGL ES 2.0.
    final boolean supportsEs2 =
            configurationInfo.reqGlEsVersion >= 0x20000
                    || (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1
                    && (Build.FINGERPRINT.startsWith("generic")
                    || Build.FINGERPRINT.startsWith("unknown")
                    || Build.MODEL.contains("google_sdk")
                    || Build.MODEL.contains("Emulator")
                    || Build.MODEL.contains("Android SDK built for x86")));

    if (supportsEs2)
    {
        // Request an OpenGL ES 2.0 compatible context.
        glSurfaceView.setEGLContextClientVersion(2);

        // Assign our renderer.
        glSurfaceView.setRenderer(renderer = new OBRenderer());
    }
    else
    {
        Toast.makeText(this, "This device does not support OpenGL ES 2.0.",
                Toast.LENGTH_LONG).show();
        return;
    }
    //
    glSurfaceView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
}
 
Example 19
Source File: GameCapturing.java    From media-for-mobile with Apache License 2.0 3 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

    ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
    ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();

    if (configurationInfo.reqGlEsVersion < 0x20000) {
        showToast("This sample requires OpenGL ES 2.0");

        return;
    }

    setContentView(R.layout.game_capturing);

    renderingMethod = GameRenderer.RenderingMethod.FrameBuffer;

    surfaceView = (GameGLSurfaceView) findViewById(R.id.surfaceView);

    gameRenderer = new GameRenderer(getApplicationContext(), uiHandler, progressListener);
    surfaceView.setRenderer(gameRenderer);

    captureButton = (ImageButton) findViewById(R.id.startCapturing);

    fps = (TextView) findViewById(R.id.fps);
    time = (TextView) findViewById(R.id.time);

    updateVideoPreview();
}
 
Example 20
Source File: GLUtil.java    From Beginner-Level-Android-Studio-Apps with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Check if the system supports OpenGL ES 2.0.
 *
 * @param context
 * @return true:supported
 */
public static boolean supportsEs2(Context context){
    final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
    return configurationInfo.reqGlEsVersion >= 0x20000;
}