Java Code Examples for android.content.pm.ConfigurationInfo

The following are top voted examples for showing how to use android.content.pm.ConfigurationInfo. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: Android_OpenGL_Demo   File: LessonThreeActivity.java   Source Code and License 6 votes vote down vote up
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mGLSurfaceView = new GLSurfaceView(this);

        // Check if the system support 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 out demo renderer, define below
//            mGLSurfaceView.setRenderer(new LessonThreeRenderer());
            mGLSurfaceView.setRenderer(new NativeThreeRenderer());
        } 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 2
Project: Android_OpenGL_Demo   File: LessonFiveActivity.java   Source Code and License 6 votes vote down vote up
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mGLSurfaceView = new LessonFiveGLSurfaceView(this);

        // Check if the system support 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 out demo renderer, define below
//            mGLSurfaceView.setRenderer(new LessonFiveRenderer(this));
            mGLSurfaceView.setRenderer(new NativeFiveRenderer(this));
        } 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
Project: Android_OpenGL_Demo   File: LessonTwoActivity.java   Source Code and License 6 votes vote down vote up
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mGLSurfaceView = new GLSurfaceView(this);

        // Check if the system support 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 out demo renderer, define below
//            mGLSurfaceView.setRenderer(new LessonTwoRenderer());
            mGLSurfaceView.setRenderer(new NativeTwoRenderer());
        } 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 4
Project: Android_OpenGL_Demo   File: LessonOneActivity.java   Source Code and License 6 votes vote down vote up
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mGLSurfaceView = new GLSurfaceView(this);

        // Check if the system support 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 out demo renderer, define below
//             mGLSurfaceView.setRenderer(new LessonOneRenderer());
            // or set a native implementation
            mGLSurfaceView.setRenderer(new NativeOneRenderer());
        } 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 5
Project: Android_OpenGL_Demo   File: LessonFourActivity.java   Source Code and License 6 votes vote down vote up
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mGLSurfaceView = new GLSurfaceView(this);

        // Check if the system support 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 out demo renderer, define below
//            mGLSurfaceView.setRenderer(new LessonFourRenderer(this));
            mGLSurfaceView.setRenderer(new NativeFourRenderer(this));
        } 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 6
Project: Android_OpenGL_Demo   File: OpenGLES2WallpaperService.java   Source Code and License 6 votes vote down vote up
void init(OpenGLEngine engine) {
	// 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.
		engine.setEGLContextClientVersion(2);

		// Set the renderer to our user-defined renderer.
		engine.setRenderer(getNewRenderer());
	} 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;
	}
}
 
Example 7
Project: Android_OpenGL_Demo   File: OpenGLES2WallpaperService.java   Source Code and License 6 votes vote down vote up
@Override
public void onCreate(SurfaceHolder surfaceHolder) {
	super.onCreate(surfaceHolder);
	
	// 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.
		setEGLContextClientVersion(2);

		// Set the renderer to our user-defined renderer.
		setRenderer(getNewRenderer());
	} 
	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;
	}			
}
 
Example 8
Project: phonk   File: OpenGLActivity.java   Source Code and License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    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 9
Project: device-info   File: SystemInfoProviderImplTest.java   Source Code and License 6 votes vote down vote up
@Before
public void setUp() throws Exception {
    mockStatic(Build.class, System.class);
    mockStaticField(Build.VERSION.class, "RELEASE", ANDROID_VERSION);
    mockStaticField(Build.VERSION.class, "SDK_INT", ANDROID_API);
    mockStaticField(Build.class, "ID", BUILD_ID);
    mockStaticField(Build.class, "CPU_ABI", ABI);
    mockStaticField(Build.class, "BOOTLOADER", BOOTLOADER);

    when(System.getProperty(SystemInfoProviderImpl.OS_NAME)).thenReturn(OS_NAME);
    when(System.getProperty(SystemInfoProviderImpl.OS_VERSION)).thenReturn(OS_VERSION);

    ActivityManager mockActivityManager = mock(ActivityManager.class);
    ConfigurationInfo mockConfigInfo = mock(ConfigurationInfo.class);
    when(mMockContext.getSystemService(Application.ACTIVITY_SERVICE)).thenReturn(mockActivityManager);
    when(mockActivityManager.getDeviceConfigurationInfo()).thenReturn(mockConfigInfo);
    when(mockConfigInfo.getGlEsVersion()).thenReturn(OPEN_GL_VERSION);


    mProvider = new SystemInfoProviderImpl(mMockContext);
}
 
Example 10
Project: NewsMe   File: GLSurfaceView.java   Source Code and License 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 11
Project: Muzesto   File: Horizon.java   Source Code and License 6 votes vote down vote up
/**
 * Basic settings for component
 *
 * @param glSurfaceView   - view that will contain the component
 * @param backgroundColor - preferable background color for correct colors blending
 */
private void initView(GLSurfaceView glSurfaceView, @ColorInt int backgroundColor) {
    // check if the system supports opengl es 2.0.
    Context context = glSurfaceView.getContext();
    final ActivityManager activityManager = (ActivityManager) context.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.
        glSurfaceView.setEGLContextClientVersion(2);

        // Set the renderer to our demo renderer, defined below.
        mRenderer = new BezierRenderer(glSurfaceView, backgroundColor);
        glSurfaceView.setRenderer(mRenderer);
        glSurfaceView.setRenderMode(GLSurfaceView.RENDERMODE_CONTINUOUSLY);
    } else {
        throw new UnsupportedOperationException();
    }
}
 
Example 12
Project: SinaVideoSdkDemo   File: GLSurfaceView.java   Source Code and License 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 13
Project: under-the-hood   File: DefaultProperties.java   Source Code and License 6 votes vote down vote up
/**
 * Convince feature to add state of multiple system features.
 * Uses {@link PackageManager#hasSystemFeature(String)} call.
 * <p>
 * See https://developer.android.com/guide/topics/manifest/uses-feature-element.html#features-reference for
 * available system features.
 *
 * @param context               can be null, but will just return an empty list
 * @param labelSystemFeatureMap a map which has ui labels as key and android system feature string
 *                              (as returned as name by {@link PackageManager#getSystemAvailableFeatures()}) as value
 * @return list of page-entries (one for each map entry)
 */
public static List<PageEntry<?>> createSystemFeatureInfo(@Nullable Context context, Map<CharSequence, String> labelSystemFeatureMap) {
    List<PageEntry<?>> entries = new ArrayList<>();
    if (context != null) {

        for (Map.Entry<CharSequence, String> entry : labelSystemFeatureMap.entrySet()) {
            boolean supported;
            if (entry.getValue().matches("^-?\\d+$")) {
                final ConfigurationInfo configurationInfo = ((ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE)).getDeviceConfigurationInfo();
                supported = configurationInfo.reqGlEsVersion >= Integer.valueOf(entry.getValue());
            } else {
                supported = context.getPackageManager().hasSystemFeature(entry.getValue());
            }
            entries.add(Hood.get().createPropertyEntry(entry.getKey(), String.valueOf(supported)));
        }
    }
    return entries;
}
 
Example 14
Project: BLE_Fun   File: GlFragment.java   Source Code and License 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final Context context = getActivity();
    final View v = inflater.inflate(getContentViewId(), container, false);

    ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    ConfigurationInfo info = am.getDeviceConfigurationInfo();
    if (info.reqGlEsVersion < 0x20000)
        throw new Error("OpenGL ES 2.0 is not supported by this device");

    loading = v.findViewById(R.id.loading);
    gLView = (GLSurfaceView) v.findViewById(R.id.gl);
    renderer = new ModelRenderer(context);
    renderer.setSurfaceView(gLView);
    gLView.setRenderer(renderer);

    loader.loadModel(getActivity(), this);
    return v;
}
 
Example 15
Project: StarWars.Android   File: TilesFrameLayout.java   Source Code and License 6 votes vote down vote up
private void initGlSurfaceView() {
    mGLSurfaceView = new StarWarsTilesGLSurfaceView(getContext());
    mGLSurfaceView.setBackgroundColor(Color.TRANSPARENT);

    // Check if the system supports OpenGL ES 2.0.
    final ActivityManager activityManager = (ActivityManager) getContext().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);

        mRenderer = new StarWarsRenderer(mGLSurfaceView, this, mAnimationDuration, mNumberOfTilesX);
        mGLSurfaceView.setEGLConfigChooser(8, 8, 8, 8, 16, 0);
        mGLSurfaceView.getHolder().setFormat(PixelFormat.TRANSPARENT);
        mGLSurfaceView.setRenderer(mRenderer);
        mGLSurfaceView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
        mGLSurfaceView.setZOrderOnTop(true);
    } else {
        throw new UnsupportedOperationException();
    }
}
 
Example 16
Project: binea_project_for_android   File: BaseOpenglActivity.java   Source Code and License 6 votes vote down vote up
@Override protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mGlSurfaceView = new GLSurfaceView(this);

    final ActivityManager am = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
    final ConfigurationInfo deviceConfigurationInfo = am.getDeviceConfigurationInfo();
    mIsSupportedEs2 =
            deviceConfigurationInfo.reqGlEsVersion >= 0x20000 || (Build.VERSION.SDK_INT
                    >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1
                    && (Build.FINGERPRINT.startsWith("generic") || Build.FINGERPRINT.startsWith(
                    "unknow") || Build.MODEL.contains("google_sdk") || Build.MODEL.contains(
                    "Emulator") || Build.MODEL.contains("Android SDK built for x86")));
    mGlSurfaceView.setEGLContextClientVersion(2);
    if (mIsSupportedEs2) {
        setGlSurfaceViewRenderer();
        mRenderSet = true;
    } else {
        Toast.makeText(this, "This device does not support OpenGl ES 2.0", Toast.LENGTH_SHORT)
                .show();
        return;
    }
    setContentView(mGlSurfaceView);
}
 
Example 17
Project: android-livewallpaper   File: PuvoGLWallpaperService.java   Source Code and License 6 votes vote down vote up
@Override
public void onCreate(SurfaceHolder surfaceHolder)
{
	super.onCreate(surfaceHolder);
	final ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
	final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
	final boolean supportsEs2 = configurationInfo.reqGlEsVersion >= 0x20000;

	if (supportsEs2) {
		puvoGLSurfaceView = new PuvoGLSurfaceView(PuvoGLWallpaperService.this);

		setEGLContextClientVersion(2);

		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
			setPreserveEGLContextOnPause(true);
			setEGConfigChooser();
		}
		setRenderer(getNewRenderer());
		setRenderMode();
	} else {
		throw new RuntimeException("system doesn't support OpenGL ES 2.0");
	}
}
 
Example 18
Project: MCESensorTagWorkshopFull   File: GlFragment.java   Source Code and License 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final Context context = getActivity();
    final View v = inflater.inflate(getContentViewId(), container, false);

    ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    ConfigurationInfo info = am.getDeviceConfigurationInfo();
    if (info.reqGlEsVersion < 0x20000)
        throw new Error("OpenGL ES 2.0 is not supported by this device");

    loading = v.findViewById(R.id.loading);
    gLView = (GLSurfaceView) v.findViewById(R.id.gl);
    renderer = new ModelRenderer(context);
    renderer.setSurfaceView(gLView);
    gLView.setRenderer(renderer);

    loader.loadModel(getActivity(), this);
    return v;
}
 
Example 19
Project: PortalLW   File: RajawaliFragment.java   Source Code and License 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mSurfaceView = new GLSurfaceView(this.getActivity());

    ActivityManager am = (ActivityManager) this.getActivity().getSystemService(Context.ACTIVITY_SERVICE);
    if (checkOpenGLVersion) {
        ConfigurationInfo info = am.getDeviceConfigurationInfo();
        if (info.reqGlEsVersion < 0x20000)
            throw new Error("OpenGL ES 2.0 is not supported by this device");
    }
    mSurfaceView.setEGLContextClientVersion(2);

    if (mMultisamplingEnabled)
        createMultisampleConfig();
}
 
Example 20
Project: PortalLW   File: RajawaliActivity.java   Source Code and License 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mSurfaceView = new GLSurfaceView(this);

    ActivityManager am = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
    if (checkOpenGLVersion) {
        ConfigurationInfo info = am.getDeviceConfigurationInfo();
        if (info.reqGlEsVersion < 0x20000)
            throw new Error("OpenGL ES 2.0 is not supported by this device");
    }
    mSurfaceView.setEGLContextClientVersion(2);
    mLayout = new FrameLayout(this);
    mLayout.addView(mSurfaceView);

    if (mMultisamplingEnabled)
        createMultisampleConfig();

    setContentView(mLayout);
}
 
Example 21
Project: PortalLW   File: RajawaliFragmentActivity.java   Source Code and License 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mSurfaceView = new GLSurfaceView(this);

    ActivityManager am = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
    if (checkOpenGLVersion) {
        ConfigurationInfo info = am.getDeviceConfigurationInfo();
        if (info.reqGlEsVersion < 0x20000)
            throw new Error("OpenGL ES 2.0 is not supported by this device");
    }
    mSurfaceView.setEGLContextClientVersion(2);
    mLayout = new FrameLayout(this);
    mLayout.addView(mSurfaceView);

    if (mMultisamplingEnabled)
        createMultisampleConfig();

    setContentView(mLayout);
}
 
Example 22
Project: IRobot-Android   File: RajawaliFragment.java   Source Code and License 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mSurfaceView = new GLSurfaceView(this.getActivity());
    
    ActivityManager am = (ActivityManager)this.getActivity().getSystemService(Context.ACTIVITY_SERVICE);
    if(checkOpenGLVersion) {
    	ConfigurationInfo info = am.getDeviceConfigurationInfo();
    	if(info.reqGlEsVersion < 0x20000)
    		throw new Error("OpenGL ES 2.0 is not supported by this device");
    }
    mSurfaceView.setEGLContextClientVersion(2);
     
    if(mMultisamplingEnabled)
    	createMultisampleConfig();
}
 
Example 23
Project: IRobot-Android   File: RajawaliActivity.java   Source Code and License 6 votes vote down vote up
protected void createSurfaceView()
{
    mSurfaceView = new GLSurfaceView(this);
    
    ActivityManager am = (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
    if(checkOpenGLVersion) {
    	ConfigurationInfo info = am.getDeviceConfigurationInfo();
    	if(info.reqGlEsVersion < 0x20000)
    		throw new Error("OpenGL ES 2.0 is not supported by this device");
    }
    mSurfaceView.setEGLContextClientVersion(2);
    
    mLayout = new FrameLayout(this);
    mLayout.addView(mSurfaceView);
    
    if(mMultisamplingEnabled)
    	createMultisampleConfig();
    
    setContentView(mLayout);
}
 
Example 24
Project: opengl   File: MainActivity.java   Source Code and License 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 25
Project: java6-android-glframework   File: AndroidGLESUtil.java   Source Code and License 6 votes vote down vote up
public static IGLVersion getGLVersion(Context context)
{
   IGLVersion glVersion = XeGLUnknown.GL_UNKNOWN;

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

   String glesVersionString = configurationInfo.getGlEsVersion();

   // This is messy...
   if (XeGLES2.GLES2_0.versionString.equals(glesVersionString))
   {
      glVersion = XeGLES2.GLES2_0;
   }
   else if (XeGLES3.GLES3_0.versionString.equals(glesVersionString))
   {
      glVersion = XeGLES3.GLES3_0;
   }
   else if (XeGLES3.GLES3_1.versionString.equals(glesVersionString))
   {
      glVersion = XeGLES3.GLES3_1;
   }

   return glVersion;
}
 
Example 26
Project: Unofficial_sensortag_app   File: GlFragment.java   Source Code and License 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final Context context = getActivity();
    final View v = inflater.inflate(getContentViewId(), container, false);

    ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    ConfigurationInfo info = am.getDeviceConfigurationInfo();
    if (info.reqGlEsVersion < 0x20000)
        throw new Error("OpenGL ES 2.0 is not supported by this device");

    loading = v.findViewById(R.id.loading);
    gLView = (GLSurfaceView) v.findViewById(R.id.gl);
    renderer = new ModelRenderer(context);
    renderer.setSurfaceView(gLView);
    gLView.setRenderer(renderer);

    loader.loadModel(getActivity(), this);
    return v;
}
 
Example 27
Project: osmdroid   File: MapFactory.java   Source Code and License 6 votes vote down vote up
/**
 * Check whether Google Maps v2 is supported on this device.
 */
public static boolean isGoogleMapsV2Supported(final Context aContext) {
	try {
		// first check if Google Play Services is available
		int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(aContext);
		if (resultCode == ConnectionResult.SUCCESS) {
			// then check if OpenGL ES 2.0 is available
			final ActivityManager activityManager =
					(ActivityManager) aContext.getSystemService(Context.ACTIVITY_SERVICE);
			final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
			return configurationInfo.reqGlEsVersion >= 0x20000;
		}
	} catch (Throwable e) {
	}
	return false;
}
 
Example 28
Project: loopback-android-getting-started   File: LessonThreeFragment.java   Source Code and License 6 votes vote down vote up
boolean detectGoogleMapsSupport() {
    // 1. Check for OpenGL ES 2.0
    final ActivityManager activityManager =
            (ActivityManager)getActivity().getSystemService(Context.ACTIVITY_SERVICE);
    final ConfigurationInfo configurationInfo =
            activityManager.getDeviceConfigurationInfo();
    if (configurationInfo.reqGlEsVersion < 0x20000) {
        Log.w("LessonThreeFragment", "Device does not support OpenGL ES 2.0");
        return false;
    }

    // 2. Check for Google Play Services availability
    final int playServicesStatus =
            GooglePlayServicesUtil.isGooglePlayServicesAvailable(getActivity());
    if (playServicesStatus != ConnectionResult.SUCCESS
            && Build.HARDWARE.contains("golfdish")) {
        // It's not possible to install or update Google Play on an emulator
        Log.w("LessonThreeFragment",
                "Detected an emulator with missing or outdated Play Services.");
        return false;
    }

    Log.i("LessonThreeFragment", "Locations will be displayed in Google Maps.");
    return true;
}
 
Example 29
Project: loopback-android-getting-started   File: LessonThreeFragment.java   Source Code and License 6 votes vote down vote up
boolean detectGoogleMapsSupport() {
    // 1. Check for OpenGL ES 2.0
    final ActivityManager activityManager =
            (ActivityManager)getActivity().getSystemService(Context.ACTIVITY_SERVICE);
    final ConfigurationInfo configurationInfo =
            activityManager.getDeviceConfigurationInfo();
    if (configurationInfo.reqGlEsVersion < 0x20000) {
        Log.w("LessonThreeFragment", "Device does not support OpenGL ES 2.0");
        return false;
    }

    // 2. Check for Google Play Services availability
    final int playServicesStatus =
            GooglePlayServicesUtil.isGooglePlayServicesAvailable(getActivity());
    if (playServicesStatus != ConnectionResult.SUCCESS
            && Build.HARDWARE.contains("golfdish")) {
        // It's not possible to install or update Google Play on an emulator
        Log.w("LessonThreeFragment",
                "Detected an emulator with missing or outdated Play Services.");
        return false;
    }

    Log.i("LessonThreeFragment", "Locations will be displayed in Google Maps.");
    return true;
}
 
Example 30
Project: MarsImagesAndroid   File: RajawaliFragment.java   Source Code and License 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mSurfaceView = new GLSurfaceView(this.getActivity());
    
    ActivityManager am = (ActivityManager)this.getActivity().getSystemService(Context.ACTIVITY_SERVICE);
    if(checkOpenGLVersion) {
    	ConfigurationInfo info = am.getDeviceConfigurationInfo();
    	if(info.reqGlEsVersion < 0x20000)
    		throw new Error("OpenGL ES 2.0 is not supported by this device");
    }
    mSurfaceView.setEGLContextClientVersion(2);
     
    if(mMultisamplingEnabled)
    	createMultisampleConfig();
}
 
Example 31
Project: MarsImagesAndroid   File: RajawaliActivity.java   Source Code and License 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mSurfaceView = new GLSurfaceView(this);
    
    ActivityManager am = (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
    if(checkOpenGLVersion) {
    	ConfigurationInfo info = am.getDeviceConfigurationInfo();
    	if(info.reqGlEsVersion < 0x20000)
    		throw new Error("OpenGL ES 2.0 is not supported by this device");
    }
    mSurfaceView.setEGLContextClientVersion(2);
    mLayout = new FrameLayout(this);
    mLayout.addView(mSurfaceView);
    
    if(mMultisamplingEnabled)
    	createMultisampleConfig();
    
    setContentView(mLayout);
}
 
Example 32
Project: MarsImagesAndroid   File: RajawaliFragmentActivity.java   Source Code and License 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mSurfaceView = new GLSurfaceView(this);
    
    ActivityManager am = (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
    if(checkOpenGLVersion) {
    	ConfigurationInfo info = am.getDeviceConfigurationInfo();
    	if(info.reqGlEsVersion < 0x20000)
    		throw new Error("OpenGL ES 2.0 is not supported by this device");
    }
    mSurfaceView.setEGLContextClientVersion(2);
    mLayout = new FrameLayout(this);
    mLayout.addView(mSurfaceView);
    
    if(mMultisamplingEnabled)
    	createMultisampleConfig();
    
    setContentView(mLayout);
}
 
Example 33
Project: BleSensorTag   File: GlFragment.java   Source Code and License 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final Context context = getActivity();
    final View v = inflater.inflate(getContentViewId(), container, false);

    ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    ConfigurationInfo info = am.getDeviceConfigurationInfo();
    if (info.reqGlEsVersion < 0x20000)
        throw new Error("OpenGL ES 2.0 is not supported by this device");

    loading = v.findViewById(R.id.loading);
    gLView = (GLSurfaceView) v.findViewById(R.id.gl);
    renderer = new ModelRenderer(context);
    renderer.setSurfaceView(gLView);
    gLView.setRenderer(renderer);

    loader.loadModel(getActivity(), this);
    return v;
}
 
Example 34
Project: CSipSimple   File: ViEAndroidGLES20.java   Source Code and License 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 35
Project: Fatigue-Detection   File: GPUImage.java   Source Code and License 5 votes vote down vote up
/**
 * Checks if OpenGL ES 2.0 is supported on the current device.
 *
 * @param context the context
 * @return true, if successful
 */
private boolean supportsOpenGLES2(final Context context) {
    final ActivityManager activityManager = (ActivityManager)
            context.getSystemService(Context.ACTIVITY_SERVICE);
    final ConfigurationInfo configurationInfo =
            activityManager.getDeviceConfigurationInfo();
    return configurationInfo.reqGlEsVersion >= 0x20000;
}
 
Example 36
Project: 3D_Wallpaper   File: GLWallpaperService.java   Source Code and License 5 votes vote down vote up
@Override
public void onCreate(SurfaceHolder surfaceHolder) {
    super.onCreate(surfaceHolder);
    glSurfaceView = new WallpaperGLSurfaceView(GLWallpaperService.this);

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

    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")));

    particlesRenderer = new ParticlesRenderer(GLWallpaperService.this);
    if (supportsEs2) {
        glSurfaceView.setEGLContextClientVersion(2);
        glSurfaceView.setRenderer(particlesRenderer);
        rendererSet = true;
    } else {
        Toast.makeText(GLWallpaperService.this, "not support egl 2.0", Toast.LENGTH_LONG);
        return;
    }

    DisplayMetrics dm = getResources().getDisplayMetrics();
    screenX = dm.widthPixels;
    screenY = dm.heightPixels;
}
 
Example 37
Project: Android_OpenGL_Demo   File: NativeLesson1Activity.java   Source Code and License 5 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
    ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
    boolean supportES2 = configurationInfo.reqGlEsVersion >= 0x2000;
    if (supportES2) {
        mGlSurfaceView = new GLSurfaceView(this);
        mGlSurfaceView.setEGLContextClientVersion(2);
        mGlSurfaceView.setRenderer(new RendererWrapper());
        rendererSet = true;
        setContentView(mGlSurfaceView);
    }
}
 
Example 38
Project: Android_OpenGL_Demo   File: LessonEightActivity.java   Source Code and License 5 votes vote down vote up
@Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mGlSurfaceView = new LessonEightGLSurfaceView(this);
        setContentView(mGlSurfaceView);
        // Check if the system support 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);

            final DisplayMetrics displayMetrics = new DisplayMetrics();
            getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);

            // Set the renderer to our demo renderer, defined below.
//            mRender = (Action) new LessonEightRenderer(this);
            mRender = (Action) new NativeEightRenderer(this);
            mGlSurfaceView.setRenderer((GLSurfaceView.Renderer) mRender, displayMetrics.density);
        } 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;
        }

    }
 
Example 39
Project: Android_OpenGL_Demo   File: OpenGLES2WallpaperService.java   Source Code and License 5 votes vote down vote up
@Override
public void onCreate(SurfaceHolder surfaceHolder) {
	super.onCreate(surfaceHolder);
	
	// 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.
		setEGLContextClientVersion(2);
		
		// On Honeycomb+ devices, this improves the performance when
		// leaving and resuming the live wallpaper.
		setPreserveEGLContextOnPause(true);

		// Set the renderer to our user-defined renderer.
		setRenderer(getNewRenderer());
	} 
	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;
	}			
}
 
Example 40
Project: Android_OpenGL_Demo   File: LessonThreeActivity.java   Source Code and License 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) 
{
	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 LessonThreeRenderer());
	} 
	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 41
Project: Android_OpenGL_Demo   File: LessonFiveActivity.java   Source Code and License 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) 
{
	super.onCreate(savedInstanceState);
	
	mGLSurfaceView = new LessonFiveGLSurfaceView(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 LessonFiveRenderer(this));
	} 
	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);
	
	// Show a short help message to the user.
	if (savedInstanceState == null || !savedInstanceState.getBoolean(SHOWED_TOAST, false))
	{
		Toast.makeText(this, R.string.lesson_five_startup_toast, Toast.LENGTH_SHORT).show();
	}
}
 
Example 42
Project: Android_OpenGL_Demo   File: LessonTwoActivity.java   Source Code and License 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) 
{
	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 LessonTwoRenderer());
	} 
	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 43
Project: Android_OpenGL_Demo   File: LessonEightActivity.java   Source Code and License 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);		

	glSurfaceView = new LessonEightGLSurfaceView(this);
	
	setContentView(glSurfaceView);

	// 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.
		glSurfaceView.setEGLContextClientVersion(2);

		final DisplayMetrics displayMetrics = new DisplayMetrics();
		getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);

		// Set the renderer to our demo renderer, defined below.
		renderer = new LessonEightRenderer(this, glSurfaceView);
		glSurfaceView.setRenderer(renderer, displayMetrics.density);
	} 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;
	}		
}
 
Example 44
Project: Android_OpenGL_Demo   File: LessonOneActivity.java   Source Code and License 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) 
{
	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 45
Project: Android_OpenGL_Demo   File: LessonFourActivity.java   Source Code and License 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) 
{
	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 LessonFourRenderer(this));
	} 
	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 46
Project: EZFilter   File: GLSurfaceView.java   Source Code and License 5 votes vote down vote up
private void checkGLESVersion() {
    if (!mGLESVersionCheckComplete) {
        mGLESVersion = SystemProperties.getInt(
                "ro.opengles.version",
                ConfigurationInfo.GL_ES_VERSION_UNDEFINED);
        if (mGLESVersion >= kGLES_20) {
            mMultipleGLESContextsAllowed = true;
        }
        if (LOG_SURFACE) {
            Log.w(TAG, "checkGLESVersion mGLESVersion =" +
                    " " + mGLESVersion + " mMultipleGLESContextsAllowed = " + mMultipleGLESContextsAllowed);
        }
        mGLESVersionCheckComplete = true;
    }
}
 
Example 47
Project: EZFilter   File: GLTextureView.java   Source Code and License 5 votes vote down vote up
private void checkGLESVersion() {
    if (!mGLESVersionCheckComplete) {
        mGLESVersion = SystemProperties.getInt("ro.opengles.version", ConfigurationInfo.GL_ES_VERSION_UNDEFINED);
        if (mGLESVersion >= kGLES_20) {
            mMultipleGLESContextsAllowed = true;
        }
        if (LOG_SURFACE) {
            Log.w(TAG, "checkGLESVersion mGLESVersion =" +
                    " " + mGLESVersion + " mMultipleGLESContextsAllowed = " + mMultipleGLESContextsAllowed);
        }
        mGLESVersionCheckComplete = true;
    }
}
 
Example 48
Project: sensor-graph-opengl-es-android   File: SensorDemoActivity.java   Source Code and License 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    sensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
    glSurfaceView = new GLSurfaceView(this);

    ActivityManager activityManager =
            (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
    ConfigurationInfo configurationInfo = activityManager
            .getDeviceConfigurationInfo();
    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) {
        initSensorGraph();
        glSurfaceView.setEGLContextClientVersion(2);
        graphRenderer = new GraphRenderer(this);
        glSurfaceView.setRenderer(graphRenderer);
        rendererSet = true;
        graphRenderer.addView(heartBeatGraph);
        graphRenderer.addView(xSensorGraph);
        graphRenderer.addView(ySensorGraph);
        graphRenderer.addView(zSensorGraph);
    } else {
        Toast.makeText(this, "This device does not support OpenGL ES 2.0.",
                Toast.LENGTH_LONG).show();
        return;
    }
    setContentView(glSurfaceView);
}
 
Example 49
Project: TAG   File: GPUImage.java   Source Code and License 5 votes vote down vote up
/**
 * Checks if OpenGL ES 2.0 is supported on the current device.
 *
 * @param context the context
 * @return true, if successful
 */
private boolean supportsOpenGLES2(final Context context) {
    final ActivityManager activityManager = (ActivityManager)
            context.getSystemService(Context.ACTIVITY_SERVICE);
    final ConfigurationInfo configurationInfo =
            activityManager.getDeviceConfigurationInfo();
    return configurationInfo.reqGlEsVersion >= 0x20000;
}
 
Example 50
Project: Device-Explorer   File: Content.java   Source Code and License 5 votes vote down vote up
public List<ItemDetails> getDetailedItems() {
    List<ItemDetails> detailedItems = new ArrayList<>();
    ConfigurationInfo c = mConfigurationInfo;
    detailedItems.add(new ItemDetails("ConfigurationInfo", c.toString()));
    detailedItems.add(new ItemDetails("glEsVersion", c.getGlEsVersion()));
    detailedItems.add(new ItemDetails("inputFeatures", c.reqInputFeatures));
    detailedItems.add(new ItemDetails("keyboardType", c.reqKeyboardType));
    detailedItems.add(new ItemDetails("navigation", c.reqNavigation));
    detailedItems.add(new ItemDetails("touchScreen", c.reqTouchScreen));

    return detailedItems;
}
 
Example 51
Project: Device-Explorer   File: Content.java   Source Code and License 5 votes vote down vote up
public String getContents() {
    StringBuilder sb = new StringBuilder();
    Formatter f = new Formatter(sb, Locale.US);
    ConfigurationInfo c = mConfigurationInfo;
    f.format("ConfigurationInfo: %s\n", c);
    f.format("glEsVersion: %s\n", c.getGlEsVersion());
    f.format("inputFeatures: %x\n", c.reqInputFeatures);
    f.format("keyboardType: %x\n", c.reqKeyboardType);
    f.format("navigation: %x\n", c.reqNavigation);
    f.format("touchScreen: %x\n", c.reqTouchScreen);
    return sb.toString();
}
 
Example 52
Project: Device-Explorer   File: Content.java   Source Code and License 5 votes vote down vote up
public static void init(Context context) {
    ITEMS.clear();
    ITEM_MAP.clear();

    sContext = context;
    sDateFormat = DateFormat.getDateFormat(context);
    sTimeFormat = DateFormat.getTimeFormat(context);
    int id = 1;
    addItem(new BuildItem(Integer.toString(id++), "Build"));
    addItem(new RootItem(Integer.toString(id++), "isRooted"));
    addItem(new BatteryItem(Integer.toString(id++), "Battery"));
    //addItem(new CamerasItem(Integer.toString(id++), "Cameras"));
    addItem(new ConfigItem(Integer.toString(id++), "Configuration", context));
    final ActivityManager activityManager =
            (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    final ConfigurationInfo configurationInfo =
        activityManager.getDeviceConfigurationInfo();
    addItem(new ConfigurationInfoItem(Integer.toString(id++), "ConfigurationInfo", configurationInfo));
    addItem(new FileInfo(Integer.toString(id++), "CpuInfo", "/proc/cpuinfo"));
    addItem(new FileInfo(Integer.toString(id++), "Crypto", "/proc/crypto"));
    addItem(new FileInfo(Integer.toString(id++), "Devices", "/proc/devices"));
    addItem(new FileInfo(Integer.toString(id++), "DiskStats", "/proc/diskstats"));
    addItem(new DisplayMetricsItem(Integer.toString(id++), "Display"));
    addItem(new EncryptItem(Integer.toString(id++), "Encryption"));
    addItem(new IdsItem(Integer.toString(id++), "IDS"));
    addItem(new FileInfo(Integer.toString(id++), "Filesystems", "/proc/filesystems"));
    addItem(new InputDeviceInfo(Integer.toString(id++), "Input Devices"));
    addItem(new FileInfo(Integer.toString(id++), "Kernel Version", "/proc/version"));
    addItem(new FileInfo(Integer.toString(id++), "LoadAvg", "/proc/loadavg"));
    addItem(new FileInfo(Integer.toString(id++), "Memory", "/proc/meminfo"));
    addItem(new FileInfo(Integer.toString(id++), "Modules", "/proc/modules"));
    addItem(new OpenGLItem(Integer.toString(id++), "OpenGL"));
    addItem(new RuntimeItem(Integer.toString(id++), "Runtime"));
    addItem(new SensorsItem(Integer.toString(id++), "Sensors", (SensorManager) context.getSystemService(Context.SENSOR_SERVICE)));
    addItem(new StorageItem(Integer.toString(id++), "Storage"));
    addItem(new FileInfo(Integer.toString(id++), "Uptime", "/proc/uptime"));
}
 
Example 53
Project: PerfectShow   File: OpenGLUtils.java   Source Code and License 5 votes vote down vote up
/**
 * Checks if OpenGL ES 2.0 is supported on the current device.
 *
 * @param context the context
 * @return true if supports OpenGL ES 2.0, otherwise false.
 */
public static boolean isOpenGLES2Supported(Context context)
{
	ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
	ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
	return configurationInfo.reqGlEsVersion >= 0x20000;
}
 
Example 54
Project: NewsMe   File: VideoView.java   Source Code and License 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 55
Project: AndroidCamera   File: GPUImage.java   Source Code and License 5 votes vote down vote up
/**
 * Checks if OpenGL ES 2.0 is supported on the current device.
 *
 * @param context the context
 * @return true, if successful
 */
private boolean supportsOpenGLES2(final Context context) {
    final ActivityManager activityManager = (ActivityManager)
            context.getSystemService(Context.ACTIVITY_SERVICE);
    final ConfigurationInfo configurationInfo =
            activityManager.getDeviceConfigurationInfo();
    return configurationInfo.reqGlEsVersion >= 0x20000;
}
 
Example 56
Project: SinaVideoSdkDemo   File: VideoView.java   Source Code and License 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 57
Project: GLMediaPlayer   File: GLToolkit.java   Source Code and License 5 votes vote down vote up
public static boolean checkSupportGLES2(Context context){
        final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
        final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
//        final boolean supportsEs2 = configurationInfo.reqGlEsVersion >= 0x20000; // works on real devices

        final boolean supportsEs2 = configurationInfo.reqGlEsVersion >= 0x20000 // modify to work on emulator
                                || (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")));

        return supportsEs2;
    }
 
Example 58
Project: apkupdater   File: NativeDeviceInfoProvider.java   Source Code and License 5 votes vote down vote up
public DeviceConfigurationProto getDeviceConfigurationProto() {
    DeviceConfigurationProto.Builder builder = DeviceConfigurationProto.newBuilder();
    addDisplayMetrics(builder);
    addConfiguration(builder);
    ConfigurationInfo configurationInfo = ((ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE)).getDeviceConfigurationInfo();
    return builder
        .addAllNativePlatform(getPlatforms())
        .addAllSystemSharedLibrary(getSharedLibraries(context))
        .addAllSystemAvailableFeature(getFeatures(context))
        .addAllSystemSupportedLocale(getLocales(context))
        .setGlEsVersion(configurationInfo.reqGlEsVersion)
        .addAllGlExtension(EglExtensionRetriever.getEglExtensions())
        .build()
        ;
}
 
Example 59
Project: miku   File: GPUImage.java   Source Code and License 5 votes vote down vote up
/**
 * Checks if OpenGL ES 2.0 is supported on the current device.
 *
 * @param context the context
 * @return true, if successful
 */
private boolean supportsOpenGLES2(final Context context) {
  final ActivityManager activityManager = (ActivityManager)
      context.getSystemService(Context.ACTIVITY_SERVICE);
  final ConfigurationInfo configurationInfo =
      activityManager.getDeviceConfigurationInfo();
  return configurationInfo.reqGlEsVersion >= 0x20000;
}
 
Example 60
Project: LiveVideo   File: ViEAndroidGLES20.java   Source Code and License 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) {
		Log.w(TAG, "IsSupported true");
		// Open GL ES 2.0 is supported.
		return true;
	}
	Log.w(TAG, "IsSupported false");
	return false;
}