当前位置: 首页>>代码示例>>Java>>正文


Java SystemUtils类代码示例

本文整理汇总了Java中org.andengine.util.system.SystemUtils的典型用法代码示例。如果您正苦于以下问题:Java SystemUtils类的具体用法?Java SystemUtils怎么用?Java SystemUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SystemUtils类属于org.andengine.util.system包,在下文中一共展示了SystemUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onLoadBitmap

import org.andengine.util.system.SystemUtils; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
	@Override
	public Bitmap onLoadBitmap(final Config pBitmapConfig, final boolean pMutable) {
		final BitmapFactory.Options decodeOptions = new BitmapFactory.Options();
		decodeOptions.inPreferredConfig = pBitmapConfig;
		decodeOptions.inDither = false;
//		decodeOptions.inScaled = false; // TODO Check how this behaves with drawable-""/nodpi/ldpi/mdpi/hdpi folders

		if (pMutable && SystemUtils.isAndroidVersionOrHigher(Build.VERSION_CODES.HONEYCOMB)) {
			decodeOptions.inMutable = pMutable;
		}

		final Bitmap bitmap = BitmapFactory.decodeResource(this.mResources, this.mDrawableResourceID, decodeOptions);

		if (pMutable) {
			return BitmapUtils.ensureBitmapIsMutable(bitmap);
		} else {
			return bitmap;
		}
	}
 
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:21,代码来源:ResourceBitmapTextureAtlasSource.java

示例2: applyEngineOptions

import org.andengine.util.system.SystemUtils; //导入依赖的package包/类
private void applyEngineOptions() {
	final EngineOptions engineOptions = this.mEngine.getEngineOptions();

	if (engineOptions.isFullscreen()) {
		ActivityUtils.requestFullscreen(this);
	}

	if (engineOptions.getAudioOptions().needsMusic() || engineOptions.getAudioOptions().needsSound()) {
		this.setVolumeControlStream(AudioManager.STREAM_MUSIC);
	}

	switch (engineOptions.getScreenOrientation()) {
		case LANDSCAPE_FIXED:
			this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
			break;
		case LANDSCAPE_SENSOR:
			if (SystemUtils.SDK_VERSION_GINGERBREAD_OR_LATER) {
				this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
			} else {
				Debug.w(ScreenOrientation.class.getSimpleName() + "." + ScreenOrientation.LANDSCAPE_SENSOR + " is not supported on this device. Falling back to " + ScreenOrientation.class.getSimpleName() + "." + ScreenOrientation.LANDSCAPE_FIXED);
				this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
			}
			break;
		case PORTRAIT_FIXED:
			this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
			break;
		case PORTRAIT_SENSOR:
			if (SystemUtils.SDK_VERSION_GINGERBREAD_OR_LATER) {
				this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
			} else {
				Debug.w(ScreenOrientation.class.getSimpleName() + "." + ScreenOrientation.PORTRAIT_SENSOR + " is not supported on this device. Falling back to " + ScreenOrientation.class.getSimpleName() + "." + ScreenOrientation.PORTRAIT_FIXED);
				this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
			}
			break;
	}
}
 
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:37,代码来源:BaseGameActivity.java

示例3: HighPerformanceVertexBufferObject

import org.andengine.util.system.SystemUtils; //导入依赖的package包/类
public HighPerformanceVertexBufferObject(final VertexBufferObjectManager pVertexBufferObjectManager, final int pCapacity, final DrawType pDrawType, final boolean pAutoDispose, final VertexBufferObjectAttributes pVertexBufferObjectAttributes) {
	super(pVertexBufferObjectManager, pCapacity, pDrawType, pAutoDispose, pVertexBufferObjectAttributes);

	this.mBufferData = new float[pCapacity];
	if (SystemUtils.SDK_VERSION_HONEYCOMB_OR_LATER) {
		this.mFloatBuffer = this.mByteBuffer.asFloatBuffer();
	} else {
		this.mFloatBuffer = null;
	}
}
 
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:11,代码来源:HighPerformanceVertexBufferObject.java

示例4: onBufferData

import org.andengine.util.system.SystemUtils; //导入依赖的package包/类
@Override
protected void onBufferData() {
	// TODO Check if, and how mow this condition affects performance.
	if (SystemUtils.SDK_VERSION_HONEYCOMB_OR_LATER) {
		// TODO Check if this is similar fast or faster than the non Honeycomb codepath.
		this.mFloatBuffer.position(0);
		this.mFloatBuffer.put(this.mBufferData);

		GLES20.glBufferData(GLES20.GL_ARRAY_BUFFER, this.mByteBuffer.capacity(), this.mByteBuffer, this.mUsage);
	} else {
		BufferUtils.put(this.mByteBuffer, this.mBufferData, this.mBufferData.length, 0);
		GLES20.glBufferData(GLES20.GL_ARRAY_BUFFER, this.mByteBuffer.limit(), this.mByteBuffer, this.mUsage);
	}
}
 
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:15,代码来源:HighPerformanceVertexBufferObject.java

示例5: onLoadBitmap

import org.andengine.util.system.SystemUtils; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override
public Bitmap onLoadBitmap(final Config pBitmapConfig, final boolean pMutable) {
	final BitmapFactory.Options decodeOptions = new BitmapFactory.Options();
	decodeOptions.inPreferredConfig = pBitmapConfig;
	decodeOptions.inDither = false;

	if (pMutable && SystemUtils.isAndroidVersionOrHigher(Build.VERSION_CODES.HONEYCOMB)) {
		decodeOptions.inMutable = pMutable;
	}

	InputStream in = null;
	try {
		in = new FileInputStream(this.mFile);
		final Bitmap bitmap = BitmapFactory.decodeStream(in, null, decodeOptions);

		if (pMutable) {
			return BitmapUtils.ensureBitmapIsMutable(bitmap);
		} else {
			return bitmap;
		}
	} catch (final IOException e) {
		Debug.e("Failed loading Bitmap in " + this.getClass().getSimpleName() + ". File: " + this.mFile, e);
		return null;
	} finally {
		StreamUtils.close(in);
	}
}
 
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:29,代码来源:FileBitmapTextureAtlasSource.java

示例6: onLoadBitmap

import org.andengine.util.system.SystemUtils; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override
public Bitmap onLoadBitmap(final Config pBitmapConfig, final boolean pMutable) {
	InputStream in = null;
	try {
		final BitmapFactory.Options decodeOptions = new BitmapFactory.Options();
		decodeOptions.inPreferredConfig = pBitmapConfig;
		decodeOptions.inDither = false;

		if (pMutable && SystemUtils.isAndroidVersionOrHigher(Build.VERSION_CODES.HONEYCOMB)) {
			decodeOptions.inMutable = pMutable;
		}

		in = this.mAssetManager.open(this.mAssetPath);

		final Bitmap bitmap = BitmapFactory.decodeStream(in, null, decodeOptions);

		if (pMutable) {
			return BitmapUtils.ensureBitmapIsMutable(bitmap);
		} else {
			return bitmap;
		}
	} catch (final IOException e) {
		Debug.e("Failed loading Bitmap in " + this.getClass().getSimpleName() + ". AssetPath: " + this.mAssetPath, e);
		return null;
	} finally {
		StreamUtils.close(in);
	}
}
 
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:30,代码来源:AssetBitmapTextureAtlasSource.java

示例7: ColorSwapBitmapTextureAtlasSourceDecorator

import org.andengine.util.system.SystemUtils; //导入依赖的package包/类
public ColorSwapBitmapTextureAtlasSourceDecorator(final IBitmapTextureAtlasSource pBitmapTextureAtlasSource, final IBitmapTextureAtlasSourceDecoratorShape pBitmapTextureAtlasSourceDecoratorShape, final int pColorKeyColorARGBPackedInt, final int pTolerance, final int pColorSwapColorARGBPackedInt, final TextureAtlasSourceDecoratorOptions pTextureAtlasSourceDecoratorOptions) {
	super(pBitmapTextureAtlasSource, pBitmapTextureAtlasSourceDecoratorShape, pTextureAtlasSourceDecoratorOptions);

	this.mColorKeyColorARGBPackedInt = pColorKeyColorARGBPackedInt;
	this.mTolerance = pTolerance;
	this.mColorSwapColorARGBPackedInt = pColorSwapColorARGBPackedInt;
	this.mPaint.setXfermode(new AvoidXfermode(pColorKeyColorARGBPackedInt, pTolerance, Mode.TARGET));
	this.mPaint.setColor(pColorSwapColorARGBPackedInt);

	if (SystemUtils.isAndroidVersionOrHigher(Build.VERSION_CODES.JELLY_BEAN)) {
		Debug.w("The class " + ColorSwapBitmapTextureAtlasSourceDecorator.class.getSimpleName() + " is deprecated for Android API Level: '" + Build.VERSION_CODES.JELLY_BEAN + "' and higher, since the class " + AvoidXfermode.class.getSimpleName() + " is deprecated since then.");
	}
}
 
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:14,代码来源:ColorSwapBitmapTextureAtlasSourceDecorator.java

示例8: execute

import org.andengine.util.system.SystemUtils; //导入依赖的package包/类
/**
 * @see <a href="https://groups.google.com/forum/?fromgroups=#!topic/android-developers/8M0RTFfO7-M">groups.google.com/forum/?fromgroups=#!topic/android-developers/8M0RTFfO7-M</a>
 */
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public static <T> void execute(final AsyncTask<T, ?, ?> pAsyncTask, final T ... pParameters) {
	if (SystemUtils.isAndroidVersionOrHigher(Build.VERSION_CODES.HONEYCOMB)) {
		pAsyncTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, pParameters);
	} else {
		pAsyncTask.execute(pParameters);
	}
}
 
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:12,代码来源:AsyncTaskUtils.java

示例9: isSupported

import org.andengine.util.system.SystemUtils; //导入依赖的package包/类
public static boolean isSupported(final Context pContext) {
	if (sSupported == null) {
		if (SystemUtils.isAndroidVersionOrHigher(Build.VERSION_CODES.ECLAIR_MR1)) {
			try {
				sSupported = SystemUtils.hasSystemFeature(pContext, PackageManager.FEATURE_BLUETOOTH);
			} catch (final SystemUtilsException e) {
				sSupported = Boolean.FALSE;
			}
		} else {
			sSupported = Boolean.FALSE;
		}
	}

	return sSupported;
}
 
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:16,代码来源:Bluetooth.java

示例10: isEthernetAvailable

import org.andengine.util.system.SystemUtils; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
public static boolean isEthernetAvailable(final Context pContext) throws ConnectivityUtilsException {
	if (SystemUtils.isAndroidVersionOrHigher(Build.VERSION_CODES.HONEYCOMB_MR2)) {
		return ConnectivityUtils.isNetworkAvailable(pContext, ConnectivityManager.TYPE_ETHERNET);
	} else {
		throw new ConnectivityUtilsException();
	}
}
 
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:9,代码来源:ConnectivityUtils.java

示例11: isEthernetConnected

import org.andengine.util.system.SystemUtils; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
public static boolean isEthernetConnected(final Context pContext) throws ConnectivityUtilsException {
	if (SystemUtils.isAndroidVersionOrHigher(Build.VERSION_CODES.HONEYCOMB_MR2)) {
		return ConnectivityUtils.isNetworkConnected(pContext, ConnectivityManager.TYPE_ETHERNET);
	} else {
		throw new ConnectivityUtilsException();
	}
}
 
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:9,代码来源:ConnectivityUtils.java

示例12: isEthernetConnectedOrConnecting

import org.andengine.util.system.SystemUtils; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
public static boolean isEthernetConnectedOrConnecting(final Context pContext) throws ConnectivityUtilsException {
	if (SystemUtils.isAndroidVersionOrHigher(Build.VERSION_CODES.HONEYCOMB_MR2)) {
		return ConnectivityUtils.isNetworkConnectedOrConnecting(pContext, ConnectivityManager.TYPE_ETHERNET);
	} else {
		throw new ConnectivityUtilsException();
	}
}
 
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:9,代码来源:ConnectivityUtils.java

示例13: isWifiHotspotSupported

import org.andengine.util.system.SystemUtils; //导入依赖的package包/类
/**
 * The check currently performed is not sufficient, as some carriers disabled this feature manually!
 */
public static boolean isWifiHotspotSupported(final Context pContext) {
	if (SystemUtils.isAndroidVersionOrLower(Build.VERSION_CODES.ECLAIR_MR1)) {
		return false;
	} else {
		final WifiManager wifiManager = WifiUtils.getWifiManager(pContext);
		try {
			final Method WifiManager_isWifiApEnabled = wifiManager.getClass().getMethod("isWifiApEnabled");
			return WifiManager_isWifiApEnabled != null;
		} catch (final Throwable t) {
			return false;
		}
	}
}
 
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:17,代码来源:WifiUtils.java

示例14: getWifiHotspotIPAddressRaw

import org.andengine.util.system.SystemUtils; //导入依赖的package包/类
/**
 * @return prefers to return an IPv4 address if found, otherwise an IPv6 address.
 * @throws org.andengine.util.WifiUtils.WifiUtilsException
 */
@TargetApi(Build.VERSION_CODES.GINGERBREAD)
public static byte[] getWifiHotspotIPAddressRaw() throws WifiUtilsException {
	try {
		byte[] ipv6Address = null;

		final Enumeration<NetworkInterface> networkInterfaceEnumeration = NetworkInterface.getNetworkInterfaces();
		while (networkInterfaceEnumeration.hasMoreElements()) {
			final NetworkInterface networkInterface = networkInterfaceEnumeration.nextElement();
			if (SystemUtils.isAndroidVersionOrLower(Build.VERSION_CODES.FROYO) || !networkInterface.isLoopback()) {
				final String networkInterfaceName = networkInterface.getName();

				if (ArrayUtils.contains(WifiUtils.HOTSPOT_NETWORKINTERFACE_NAMES, networkInterfaceName)) {
					final Enumeration<InetAddress> inetAddressEnumeration = networkInterface.getInetAddresses();
					while (inetAddressEnumeration.hasMoreElements()) {
						final InetAddress inetAddress = inetAddressEnumeration.nextElement();
						if (!inetAddress.isLoopbackAddress()) {
							final byte[] ipAddress = inetAddress.getAddress();
							if (ipAddress.length == IPUtils.IPV4_LENGTH) {
								return ipAddress;
							} else {
								ipv6Address = ipAddress;
							}
						}
					}
				}
			}
		}

		if (ipv6Address != null) {
			return ipv6Address;
		} else {
			throw new WifiUtilsException("No IP bound to '" + Arrays.toString(WifiUtils.HOTSPOT_NETWORKINTERFACE_NAMES) + "'!");
		}
	} catch (final SocketException e) {
		throw new WifiUtilsException("Unexpected error!", e);
	}
}
 
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:42,代码来源:WifiUtils.java

示例15: getEmulatorIPAddressRaw

import org.andengine.util.system.SystemUtils; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.GINGERBREAD)
public static byte[] getEmulatorIPAddressRaw() throws WifiUtilsException {
	try {
		byte[] ipv6Address = null;

		final Enumeration<NetworkInterface> networkInterfaceEnumeration = NetworkInterface.getNetworkInterfaces();
		while (networkInterfaceEnumeration.hasMoreElements()) {
			final NetworkInterface networkInterface = networkInterfaceEnumeration.nextElement();
			if (SystemUtils.isAndroidVersionOrLower(Build.VERSION_CODES.FROYO) || !networkInterface.isLoopback()) {
				final Enumeration<InetAddress> inetAddressEnumeration = networkInterface.getInetAddresses();
				while (inetAddressEnumeration.hasMoreElements()) {
					final InetAddress inetAddress = inetAddressEnumeration.nextElement();
					if (!inetAddress.isLoopbackAddress()) {
						final byte[] ipAddress = inetAddress.getAddress();
						if (ipAddress.length == IPUtils.IPV4_LENGTH) {
							return ipAddress;
						} else {
							ipv6Address = ipAddress;
						}
					}
				}
			}
		}

		if (ipv6Address != null) {
			return ipv6Address;
		} else {
			throw new WifiUtilsException("No IP found that is not bound to localhost!");
		}
	} catch (final SocketException e) {
		throw new WifiUtilsException("Unexpected error!", e);
	}
}
 
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:34,代码来源:WifiUtils.java


注:本文中的org.andengine.util.system.SystemUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。