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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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);
}